[LLVMbugs] [Bug 1680] New: x86 inline asm generates wrong code

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Sep 18 13:08:32 PDT 2007


http://llvm.org/bugs/show_bug.cgi?id=1680

           Summary: x86 inline asm generates wrong code
           Product: new-bugs
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: astrange at ithinksw.com
                CC: llvmbugs at cs.uiuc.edu


This is the llvm 2.1 prerelease for darwin/x86.

> /usr/local/llvmgcc/bin/llvm-gcc -v
Using built-in specs.
Target: i686-apple-darwin8
Configured with: ../src/configure
--prefix=/Users/lattner/2.1/llvm-gcc4.0-2.1.source/obj/../install
--enable-llvm=/Users/lattner/2.1/llvm-2.1 --enable-languages=c,c++,objc,obj-c++
--with-arch=nocona --with-tune=generic
--with-gxx-include-dir=/usr/include/c++/4.0.0 --build=i686-apple-darwin8
--host=i686-apple-darwin8 --target=i686-apple-darwin8 : (reconfigured)
../src/configure
--prefix=/Users/lattner/2.1/llvm-gcc4.0-2.1.source/obj/../install
--enable-llvm=/Users/lattner/2.1/llvm-2.1 --enable-languages=c,c++,objc,obj-c++
--with-arch=nocona --with-tune=generic
--with-gxx-include-dir=/usr/include/c++/4.0.0 --build=i686-apple-darwin8
--host=i686-apple-darwin8 --target=i686-apple-darwin8 --program-prefix=llvm-
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5449)(LLVM build 2.1)

compared to:
> /usr/local/gcc43/bin/gcc -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: ../gcc/configure --prefix=/usr/local/gcc43 --with-arch=nocona
--with-tune=nocona --with-gmp=/sw --with-system-zlib
--enable-languages=c,c++,objc,obj-c++
Thread model: posix
gcc version 4.3.0 20070915 (experimental) (GCC) 

> /usr/local/llvmgcc/bin/llvm-gcc -fstrict-aliasing -O3 -fomit-frame-pointer -mdynamic-no-pic -march=nocona -mtune=nocona -S h264-cabac.i -o llvm-gcc21.s

This asm has these constraints:
        :"=&a"(bit)
        :"r"(state), "r"(c)
        : "%""ecx", "%ebx", "%edx", "%esi", "memory"

GCC 4.3 allocates the first three to eax, edi, and ebp.
LLVM uses eax, ecx, and edx.
This generates wrong code since ecx and edx are already in the clobber list.

BTW, I think gcc 4.3 generates better code for the C version; llvm uses (%esp)
instead of a register in one important part.

FSF gcc doesn't have -mdynamic-no-pic, so I had to compile with -fno-pic, which
lets it generate "_ff_h264_lps_range(%edi,%eax,2)" directly instead of using
$non_lazy_ptr. Since that seems to work and the asm does it anyway, I'm not
really sure what the difference is.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list