https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63445
--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > Found new range for j_9: [i_15 + 1, +INF] > > Visiting statement: > _6 = j_9 - i_15; > Found new range for _6: [1, +INF(OVF)] > > i_15 could be negative and thus j_9 - i_15 could well overflow the input > range at the +INF side. (i_15 is [-INF, j_5(D) + -1]) Yes, the range is as expected here but... > I believe we are just better in propagating the ranges here and 4.9 > computed _6 as VARYING (and thus not applying the optimization). ...we actually don't apply any optimization to the code: Value ranges after VRP: n_1: [1, +INF] EQUIVALENCES: { n_7 c_8 n_16 } (3 elements) _2: [1, +INF] EQUIVALENCES: { n_7 n_16 } (2 elements) pretmp_3: ~[0, 0] i_4(D): VARYING j_5(D): VARYING _6: [1, +INF(OVF)] n_7: [0, +INF] [...] <bb 2>: if (i_4(D) < j_5(D)) goto <bb 3>; else goto <bb 7>; <bb 3>: _6 = j_5(D) - i_4(D); n_7 = (unsigned int) _6; if (_6 != 0) goto <bb 4>; else goto <bb 7>; The range of n_7 is suboptimal and the test on _6 can be eliminated.