From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5205 invoked by alias); 4 Mar 2010 22:08:58 -0000 Received: (qmail 5144 invoked by uid 48); 4 Mar 2010 22:08:40 -0000 Date: Thu, 04 Mar 2010 22:08:00 -0000 Message-ID: <20100304220840.5143.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/43262] inline asm with -O2 breaks logic if comarisons are involved In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" 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: 2010-03/txt/msg00426.txt.bz2 ------- Comment #1 from pinskia at gcc dot gnu dot org 2010-03-04 22:08 ------- The problem you are seeing is Intel vs AT&T asm formats. GNU as defaults to AT&T format in that it is src, dst. So you have the operands swapped. Note also you also don't clobber the flags register as bsr sets the Zero flag. asm volatile("bsr %1, %0" : "=r" (n) : "r" (x) : "flags"); Is the correct code you want. It just happened to work at -O0 because the register allocator used the same registers for the input and output. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43262