https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94145
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- So what prevents GIMPLE from doing the transform to an indirect call and hoisting the call address computation out of the loop? I fear your volatile marking is papering over an entirely different issue. Of course it will likely work as a workaround since nobody is going to do that above mentioned dance. Maybe code like void foo(); void bar() { void (volatile fn*)() = foo; void (fn2 *)() = fn; for (int i = 0; i<10000; ++i) fn2(); } will expose the same "issue" whatever it really is?