From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7648 invoked by alias); 20 Aug 2008 13:45:55 -0000 Received: (qmail 7624 invoked by uid 22791); 20 Aug 2008 13:45:52 -0000 X-Spam-Check-By: sourceware.org Received: from ugmailsa.ugent.be (HELO ugmailsa.ugent.be) (157.193.49.116) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 20 Aug 2008 13:45:10 +0000 Received: from localhost (localhost [127.0.0.1]) by ugmailsa.ugent.be (Postfix) with ESMTP id C475F307F59 for ; Wed, 20 Aug 2008 15:45:07 +0200 (CEST) Received: from ugmailsa.ugent.be ([127.0.0.1]) by localhost (ugmailsa.ugent.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DqEzcE4tWsbt for ; Wed, 20 Aug 2008 15:45:07 +0200 (CEST) Received: from cedar.ugent.be (cedar.ugent.be [157.193.49.14]) by ugmailsa.ugent.be (Postfix) with ESMTP id 5E783306D42 for ; Wed, 20 Aug 2008 15:45:07 +0200 (CEST) Received: from cage.ugent.be ([157.193.53.8]) by cedar.ugent.be with ESMTP; 20 Aug 2008 15:45:07 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAEC8q0idwTUI/2dsb2JhbAC1coFZ Received: from [127.0.0.1] (cage [157.193.53.8]) by cage.ugent.be (Postfix) with ESMTP id 7E86E3529; Wed, 20 Aug 2008 15:45:06 +0200 (CEST) Message-ID: <48AC1FC6.4060308@cage.ugent.be> Date: Wed, 20 Aug 2008 13:47:00 -0000 From: Jeroen Demeyer User-Agent: Thunderbird 2.0.0.16 (X11/20080728) MIME-Version: 1.0 To: Ian Lance Taylor CC: gcc-help@gcc.gnu.org Subject: Re: Inline assembly constraints question References: <48A937FE.30100@cage.ugent.be> In-Reply-To: Content-Type: multipart/mixed; boundary="------------030100030803010605070204" X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00201.txt.bz2 This is a multi-part message in MIME format. --------------030100030803010605070204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1565 Ian Lance Taylor wrote: > Jeroen Demeyer writes: > >> I have a C++ program (i386 target) which has a piece of inline >> assembly with the following constraints: >> >> asm(/* Some asm code */ >> : "=&rm" (n0), "=&r" (n1), "=&r" (n2) >> : "2" (n0), "1" (n1), "g" (n2), "cI" (s) >> ); >> >> When compiled with g++ 4.1.2 (CXXFLAGS=-O2 -march=pentium4) the >> operands %0 and %5 get the same memory address, even though they refer >> to distinct variables (n0 and n2). > > It would help to see the types of the variables. Is n2 a pointer? > Also it would help to see the actual values that wind up getting > passed in. n0, n1, n2 are unsigned long (members of the same C++ class, the asm statement is in a member function), s is unsigned char. > I think more details would help. For example, run gcc with the -dg > option, look at FILENAME.xxx.greg, and show us the insn corresponding > to the asm statement. This is the full asm statement: asm("# number_t& number_t::operator>>=(unsigned char s)\n" " shrdl %6, %4, %3\n" " movl %3, %0\n" " movl %5, %2\n" " shrdl %6, %2, %1\n" " shrl %6, %2\n" : "=&rm" (n0), "=&r" (n1), "=&r" (n2) : "2" (n0), "1" (n1), "g" (n2), "cI" (s) ); The code generated is the following: shrdl %cl, %esi, %eax movl %eax, -4384(%ebp) movl -4384(%ebp), %eax shrdl %cl, %eax, %esi shrl %cl, %eax As you can see, %0 and %5 both become -4384(%ebp). See attachment for the output from -dg. I hope this clarifies the problem. Thank you! --------------030100030803010605070204 Content-Type: text/plain; name="test.cpp.37.greg" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="test.cpp.37.greg" Content-length: 2503 (insn:HI 809 1339 1338 109 (parallel [ (set (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int -4384 [0xffffeee0])) [88 t$n0.805+0 S4 A8]) (asm_operands:SI ("# number_t& number_t::operator>>=(unsigned char s) shrdl %6, %4, %3 movl %3, %0 movl %5, %2 shrdl %6, %2, %1 shrl %6, %2 ") ("=&rm") 0 [ (reg:SI 0 ax) (reg:SI 4 si) (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int -4384 [0xffffeee0])) [88 t$n2+0 S4 A8]) (reg:QI 2 cx) ] [ (asm_input:SI ("2")) (asm_input:SI ("1")) (asm_input:SI ("g")) (asm_input:QI ("cI")) ] ("i386/number96.h") 148)) (set (reg:SI 4 si) (asm_operands:SI ("# number_t& number_t::operator>>=(unsigned char s) shrdl %6, %4, %3 movl %3, %0 movl %5, %2 shrdl %6, %2, %1 shrl %6, %2 ") ("=&r") 1 [ (reg:SI 0 ax) (reg:SI 4 si) (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int -4384 [0xffffeee0])) [88 t$n2+0 S4 A8]) (reg:QI 2 cx) ] [ (asm_input:SI ("2")) (asm_input:SI ("1")) (asm_input:SI ("g")) (asm_input:QI ("cI")) ] ("i386/number96.h") 148)) (set (reg:SI 0 ax) (asm_operands:SI ("# number_t& number_t::operator>>=(unsigned char s) shrdl %6, %4, %3 movl %3, %0 movl %5, %2 shrdl %6, %2, %1 shrl %6, %2 ") ("=&r") 2 [ (reg:SI 0 ax) (reg:SI 4 si) (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int -4384 [0xffffeee0])) [88 t$n2+0 S4 A8]) (reg:QI 2 cx) ] [ (asm_input:SI ("2")) (asm_input:SI ("1")) (asm_input:SI ("g")) (asm_input:QI ("cI")) ] ("i386/number96.h") 148)) (clobber (reg:QI 19 dirflag)) (clobber (reg:QI 18 fpsr)) (clobber (reg:QI 17 flags)) ]) -1 (nil) (nil)) --------------030100030803010605070204--