https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92346
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This code is clearly undefined.
First you say eax is in eax and then then you say the register gets clobbered
by the inline-asm (and is set by the inline-asm).
But you only set the lower bits of the eax to be 1 in the inline-asm.
In the -O0 case, what is happening is eax is both the output register and the
clobbered.
In the -O2 case, the eax is not used as the output register but rather a
different one as eax would conflict with the clobber register.
You can see that effect by outputing %0 and %1 in the inline-asm template.
Basically the inline-asm is broken and is not expected to work the way you
expected it to work.