https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111445
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- -Os -fallow-store-data-races -fdisable-tree-sccp -fno-tree-loop-im makes the case simpler to look at, IVOPTs only mangles the last loop there: Analyzing # of iterations of loop 2 exit condition [d_26 + 1, + , 1](no_overflow) <= 1 bounds on difference of bases: -255 ... 0 result: zero if d_26 > 1 # of iterations 1 - (unsigned int) d_26, bounded by 1 number of iterations 1 - (unsigned int) d_26; zero if d_26 > 1 .. Selected IV set for loop 2 at t.c:22, 2 avg niters, 1 IVs: Candidate 10: Var befor: ivtmp.26_28 Var after: ivtmp.26_29 Incr POS: at end IV struct: Type: unsigned int Base: (unsigned int) (d_26 + 1) Step: 1 Biv: N Overflowness wrto loop niter: No-overflow changing + _31 = d_26 + 1; + ivtmp.26_30 = (unsigned int) _31; goto <bb 6>; [100.00%] <bb 5> [local count: 118111600]: b.6_7 = b; _8 = (int) b.6_7; check (_8); - e_21 = e_15 + 1; + ivtmp.26_29 = ivtmp.26_28 + 1; <bb 6> [local count: 236223200]: - # e_15 = PHI <0(10), e_21(5)> + # ivtmp.26_28 = PHI <ivtmp.26_30(10), ivtmp.26_29(5)> _9 = (unsigned char) d_26; _10 = _9 + 1; _11 = (int) _10; - _12 = (int) e_15; - _13 = _11 + _12; - if (_13 <= 1) + _32 = (int) ivtmp.26_28; + if (_32 <= 1) goto <bb 5>; [50.00%] else goto <bb 7>; [50.00%]