This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/48347] The wrong assembler code is emitted for my architecture


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

--- Comment #2 from Norman Goldstein <normvcr at telus dot net> 2011-03-30 00:16:54 UTC ---
I installed and built the source RPM mediatomb-0.12.1-5.fc14.src.rpm, using the
default compile flags, -g -O2, and this is fine, except that debugging was
difficult, so I rebuilt using only -g. This is when the assembler complained:

Quote:
../src/zmm/atomic.h: Assembler messages:
../src/zmm/atomic.h:81: Error: bad register name `%sil'
Line 81 in atomic.h is the inline asm statement:

Code:

    static inline bool atomic_dec(mt_atomic_t *at)
    {
        unsigned char c;
        __asm__ __volatile__(
            ASM_LOCK "decl %0; sete %1"
            :"=m" (at->x), "=g" (c)
            :"m" (at->x)
            :"cc"
        );
        return (c!=0);
    }

I edited the compile command, replacing, -c with -S, and .o with .asm, to take
a look at the generated assembler code. Here is the relevant snippet:

Code:

# 81 "../src/zmm/atomic.h" 1
    lock; decl (%eax); sete %sil

Sure enough, the gcc inline module inserted a reference to the "%sil" register,
which is not part of the x86 32-bit architecture. The only difference on the
command line was the absence of the "-O2" flag.

I did some more experimenting, and found that "-O1" produces proper code. Then
I did a compile replacing "-O1" with all the implied optimization flags, but
the .asm file had the improper reference to "%sil" !

The gcc documentation does explain that "-On" is not exactly equivalent to
using the implied flags, and I guess that my experience, here, corroborates
this.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]