------- 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