From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29210 invoked by alias); 30 Mar 2011 00:17:05 -0000 Received: (qmail 29202 invoked by uid 22791); 30 Mar 2011 00:17:04 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_MV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Mar 2011 00:16:59 +0000 From: "normvcr at telus dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug inline-asm/48347] The wrong assembler code is emitted for my architecture X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: inline-asm X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: normvcr at telus dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 30 Mar 2011 01:26:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg03099.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48347 --- Comment #2 from Norman Goldstein 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.