This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/43262] inline asm with -O2 breaks logic if comarisons are involved
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Mar 2010 22:08:40 -0000
- Subject: [Bug c++/43262] inline asm with -O2 breaks logic if comarisons are involved
- References: <bug-43262-18872@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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