https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103168
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> --- This is simple (and fairly common) case we don't optimize struct a { int a; static __attribute__ ((noinline)) int ret (int v) {return v;} __attribute__ ((noinline)) int inca () {return a++;} }; int test() { struct a av; av.a=1; int val = av.ret (0) + av.inca(); av.a=2; return val + av.ret(0) + av.inca(); } what ret is const however becaue it is in COMDAT group we only detect it as pure which makes GVN to give up on proving that its value did not change over av.a=2 store. We could easily work this out from modref summary (which says that function makes no memory load)