https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82320
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Starting iteration 37161 Value numbering md_11 stmt = md_11 = PHI <md_21(D)(2), md_10(5)> Setting value number of md_11 to md_21(D) (changed) Value numbering md_10 stmt = md_10 = PHI <lq_24(D)(7), md_9(4)> Setting value number of md_10 to lq_24(D) (changed) Value numbering md_9 stmt = md_9 = PHI <md_10(5), md_11(8)> Setting value number of md_9 to md_21(D) (changed) Starting iteration 37162 Value numbering md_11 stmt = md_11 = PHI <md_21(D)(2), md_10(5)> Setting value number of md_11 to lq_24(D) (changed) Value numbering md_10 stmt = md_10 = PHI <lq_24(D)(7), md_9(4)> Setting value number of md_10 to md_21(D) (changed) Value numbering md_9 stmt = md_9 = PHI <md_10(5), md_11(8)> Setting value number of md_9 to lq_24(D) (changed) Starting iteration 37163 Value numbering md_11 stmt = md_11 = PHI <md_21(D)(2), md_10(5)> Setting value number of md_11 to md_21(D) (changed) Value numbering md_10 stmt = md_10 = PHI <lq_24(D)(7), md_9(4)> Setting value number of md_10 to lq_24(D) (changed) Value numbering md_9 stmt = md_9 = PHI <md_10(5), md_11(8)> Setting value number of md_9 to md_21(D) (changed) ... So we iterate between the different leaders for "undefined". I suppose not considering lq_24(D) -> md_21(D) a change in values would fix this. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 253149) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -3355,6 +3355,12 @@ set_ssa_val_to (tree from, tree to) if (currval != to && !operand_equal_p (currval, to, 0) + /* Different undefined SSA names are not actually different. See + PR82320 for a testcase were we'd otherwise not terminate iteration. */ + && !(TREE_CODE (currval) == SSA_NAME + && TREE_CODE (to) == SSA_NAME + && ssa_undefined_value_p (currval, false) + && ssa_undefined_value_p (to, false)) /* ??? For addresses involving volatile objects or types operand_equal_p does not reliably detect ADDR_EXPRs as equal. We know we are only getting invariant gimple addresses here, so can use