https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103052
--- Comment #10 from Jan Hubicka <hubicka at gcc dot gnu.org> --- There is wrong order of conditionals in code merging previously known info with current info. IPA propagation gets state NEITHER by walking around the non-trivial cycle while function was earlier detected as PURE. It is bit weird that IPA code does not ndetect PURE like local code. The catch is that we get SCC involving noreturn edge which is not really a SCC for pure analysis but it is SCC for const (since noreturn functions never modify global memory after returning) diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index a332940b55d..b438eb718a1 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1782,9 +1782,9 @@ propagate_pure_const (void) if (w_l->state_previously_known != IPA_NEITHER && this_state > w_l->state_previously_known) { - this_state = w_l->state_previously_known; if (this_state == IPA_NEITHER) - this_looping = w_l->looping_previously_known; + this_looping = w_l->looping_previously_known; + this_state = w_l->state_previously_known; } if (!this_looping && self_recursive_p (w)) this_looping = true;