https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94836
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so it's not that easy to do. Consider int f(int x) { static int s; if (!s) s = x; return s; } which we cannot optimize in this way. VN would need to work in a way assigning the value 0 to 's' optimistically and if it eventually arrives at s = x it would need to invalidate that optimistic assumption and iterate. That is it would need to see the function as int f(int x) { static int s; # s = PHI <0, s'> if (!s) s = x; return s; s' = s; goto start; } with the goto of course not explicit. I suppose rather than integrating the feature into their value-numbering scheme compilers implement special purpose optimization (IIRC this pattern appears in SPEC).