In the following inline assembly statement (the second one in the attached
program), the operands %0 and %5 are stored in exactly the same memory address
-44(%ebp), even though they refer to different variables (and all the output
constraints have the earlyclobber modifier).

asm("   shrdl %6, %4, %3\n"
    "   movl %3, %0\n"
    "   movl %5, %2\n"
    "   shrdl %6, %2, %1\n"
    "   shrl %6, %2\n"
    : "=&rm" (d0), "=&r" (d1), "=&r" (d2)
    : "2" (c0), "1" (c1), "g" (c2), "cI" (s)
    : "%eax", "%esi", "%edi", "cc"
);

This code is compiled as
    shrdl %cl, %edx, %ebx
    movl %ebx, -40(%ebp)
    movl -40(%ebp), %ebx
    shrdl %cl, %ebx, %edx
    shrl %cl, %ebx


Command line:
gcc-4.2.4 -O1 -save-temps asmtest.c -c -o asmtest.o

Note: gcc 4.3.1 does not seem to have this problem.


Output of gcc -v:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.4/work/gcc-4.2.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.2.4
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.4/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-multilib --enable-libmudflap
--disable-libssp --disable-libgcj --with-arch=i686
--enable-languages=c,c++,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.4 (Gentoo 4.2.4)


-- 
           Summary: unrelated variables get the same memory address in
                    inline assembly
           Product: gcc
           Version: 4.2.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jdemeyer at cage dot ugent dot be
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195

Reply via email to