https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108712
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |inline-asm, | |missed-optimization --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The inline-asm is causing GCC not to optimize the code. Doing the following on x86_64 allows GCC to optimize the g load/stores out of the loop: static volatile int flag; static int g; void func(void) { for(int i = 0; i < 20; i++) { ++g; if (flag) { flag = 0; } } }