https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77839
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- SCC consists of: .MEM_16 .MEM_15 .MEM_35 .MEM_26 ez_12 .MEM_14 wo_37 _5 _6 hy.3_7 _8 .MEM_32 hy.0_1 ez_28 _3 wo_40 Value numbering wo_37 stmt = wo_37 = PHI <0(4), wo_40(5)> Setting value number of wo_37 to ez_12 (changed) Value numbering _3 stmt = _3 = ez_28 ^ wo_37; Applying pattern match.pd:580, gimple-match.c:33849 Match-and-simplified ez_28 ^ wo_37 to 0 RHS ez_28 ^ wo_37 simplified to 0 Setting value number of _3 to 0 (changed) Value numbering wo_40 stmt = wo_40 = _3; Setting value number of wo_40 to 0 (changed) Value numbering wo_37 stmt = wo_37 = PHI <0(4), wo_40(5)> Setting value number of wo_37 to 0 (changed) Value numbering _3 stmt = _3 = ez_28 ^ wo_37; Applying pattern match.pd:83, gimple-match.c:33640 Match-and-simplified ez_28 ^ wo_37 to ez_12 RHS ez_28 ^ wo_37 simplified to ez_12 Setting value number of _3 to ez_12 (changed) Value numbering wo_40 stmt = wo_40 = _3; Setting value number of wo_40 to ez_12 (changed) ... <bb 6>: # tc_11 = PHI <0(4), tc_31(5)> # ez_12 = PHI <0(4), ez_28(5)> # b8_13 = PHI <0(4), b8_30(5)> # wo_37 = PHI <0(4), wo_40(5)> so we're iterating between "same PHI" and same value. This is because only when wo_40 == ez_12 we detect that it is actually zero ... we fail to apply the wo_40 == 0 -> wo_37 == 0 -> ez_12 == 0 step when we in the first iteration numbered wo_37 to ez_12. As the comment says: /* First see if it is equivalent to a phi node in this block. We prefer this as it allows IV elimination - see PRs 66502 and 67167. */ we have the issue that the algorithm doesn't handle all cases, this now shows we even can oscillate between them :/