https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102920
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- So the "logic" is that # var_120_lsm.9_7 = PHI <_42(6), _29(D)(5)> # var_123_lsm.11_13 = PHI <_26(D)(6), _1(5)> can be considered equal since _42 and _26(D) are optimistically equal and _29(D) and _1 are optimistically equal as well. But we may only use optimistic equality when merging values on different edges, not when merging values on the same edge - in particular we may not choose the undef value on any edge when there's a not undef value as well. Hmm, we're also treating a[i][undef] and a[undef][i] as the same but there I guess both undefs are "used" and thus both expressions invoke undefined behavior. While with the PHIs we don't know which edge will be taken and thus which copy will result in undefined behavior.