https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112961
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- So in this case VN doesn't "fix" it because Value numbering stmt = _29 = MAX_EXPR <_16, prephitmp_18>; Setting value number of _29 to _29 (changed) Making available beyond BB3 _29 for value _29 Value numbering stmt = prephitmp_23 = _29; Setting value number of prephitmp_23 to _29 (changed) ... Keeping eliminated stmt live as copy because of out-of-region uses as the loop header is using this on the backedge and we are explicitly excluding the latch block from processing to avoid CSE of PHIs(?). I think including the latch block should be fine, but PR90402 is what I added this special case for (the testcase still passes after reverting).