https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68974
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- GCC is allowed to reorder asm in assembly just not the order of execution of them. Basic blocks are not expected to be in the same order as they are written. This is not a GCC bug but rather your assumptions about inline-asm and basic blocks. Also note GCC is allowed to duplicate inline-asm statements which is what is happening at -O2.