https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71661
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- This to me looks like some transformation of a loop that doesn't properly adjust the number of iterations. During vrp1 loop2 is: loop_2 (header = 11, latch = 13, niter = c_23 + 1 <= 3 ? 2 - c_23 : 0, upper_bound = 3, likely_upper_bound = 3) { bb_11 (preds = {bb_5 bb_13 }, succs = {bb_6 }) { <bb 11>: # c_5 = PHI <c_23(5), c_29(13)> # d_7 = PHI <d_24(5), d_8(13)> # .MEM_11 = PHI <.MEM_25(5), .MEM_12(13)> # .MEM_18 = VDEF <.MEM_11> a = 2; c_19 = c_5 + 1; } bb_6 (preds = {bb_11 }, succs = {bb_13 bb_7 }) { <bb 6>: # c_6 = PHI <c_19(11)> # d_8 = PHI <d_7(11)> # .MEM_12 = PHI <.MEM_18(11)> if (c_6 <= 2) goto <bb 13>; else goto <bb 7>; } bb_13 (preds = {bb_6 }, succs = {bb_11 }) { <bb 13>: c_29 = ASSERT_EXPR <c_6, c_6 <= 2>; goto <bb 11>; } } after dce it is: loop_2 (header = 6, latch = 6, niter = , upper_bound = 3, likely_upper_bound = 3) { bb_6 (preds = {bb_5 bb_6 }, succs = {bb_6 bb_7 }) { <bb 6>: # c_5 = PHI <0(5), c_19(6)> # d_7 = PHI <d_24(5), d_7(6)> # .MEM_11 = PHI <.MEM_25(5), .MEM_18(6)> # .MEM_18 = VDEF <.MEM_11> a = 2; c_19 = c_5 + 1; if (c_19 <= 2) goto <bb 6>; else goto <bb 7>; } } so again reasonable. but ch pass turns this into: loop_2 (header = 11, latch = 7, niter = , upper_bound = 3, likely_upper_bound = 3) { bb_7 (preds = {bb_8 bb_11 }, succs = {bb_11 }) { <bb 7>: # c_9 = PHI <0(8), c_19(11)> # d_25 = PHI <d_20(8), d_7(11)> # .MEM_24 = PHI <.MEM_18(8), .MEM_18(11)> } bb_11 (preds = {bb_7 bb_2 bb_5 }, succs = {bb_7 bb_8 }) { <bb 11>: # c_5 = PHI <c_9(7), 0(2), 0(5)> # d_7 = PHI <d_25(7), d_16(D)(2), 0(5)> # .MEM_11 = PHI <.MEM_24(7), .MEM_15(2), .MEM_10(5)> # .MEM_18 = VDEF <.MEM_11> a = 2; c_19 = c_5 + 1; if (c_19 <= 2) goto <bb 7>; else goto <bb 8>; } bb_8 (preds = {bb_11 }, succs = {bb_7 bb_10 }) { <bb 8>: d_20 = d_7 + 1; if (d_20 <= 1) goto <bb 7>; else goto <bb 10>; } } (basically collapses 2 loops into one), and the upper_bound/likely_upper_bound is just wrong here, because the loop latch is executed exactly 5 times if the loop is entered from bb 5 (that is the case at runtime), or 2 times + UB (if entered from bb 2) - with c_19 being 1, 2, 3, 1, 2.