https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66652
--- Comment #2 from vries at gcc dot gnu.org --- Created attachment 35865 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35865&action=edit follow-up patch for demonstrator patch This patch in addition allows transform_to_exit_first_loop_alt for unsigned loop counters. But it's not generic enough to also handle the fortran testcases in https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01234.html . For parloops-exit-first-loop-alt.f95, we have: ... foo (integer(kind=4)D.8 & restrict nrD.3381) { integer(kind=4) ii; integer(kind=4) _6; integer(kind=4) _7; integer(kind=8) _8; integer(kind=4) _9; integer(kind=4) _10; integer(kind=4) _11; integer(kind=4) _12; integer(kind=4) _13; integer(kind=8) _16; unsigned int _19; integer(kind=4) _20; integer(kind=4) _22; integer(kind=4) _23; integer(kind=4) _24; signed int ivtmp_27; signed int ivtmp_28; <bb 2>: _6 = *nr_5(D); _7 = _6 + -1; if (_7 >= 0) goto <bb 4>; else goto <bb 3>; <bb 3>: return; <bb 4>: _20 = _6 + -1; _19 = (unsigned int) _20; <bb 10>: if (_19 > 199) goto <bb 11>; else goto <bb 12>; <bb 11>: <bb 5>: # ivtmp_27 = PHI <0(11), ivtmp_28(7)> ii_1 = ivtmp_27; _8 = (integer(kind=8)) ii_1; _9 = __BLNK__.a[_8]; _11 = __BLNK__.b[_8]; _12 = _9 + _11; _13 = _12 + 25; __BLNK__.c[_8] = _13; ii_15 = ii_1 + 1; if (ivtmp_27 < _19) goto <bb 7>; else goto <bb 6>; <bb 6>: goto <bb 3>; <bb 7>: ivtmp_28 = ivtmp_27 + 1; goto <bb 5>; <bb 12>: <bb 8>: # ii_18 = PHI <0(12), ii_26(9)> _16 = (integer(kind=8)) ii_18; _10 = __BLNK__.a[_16]; _23 = __BLNK__.b[_16]; _22 = _10 + _23; _24 = _22 + 25; __BLNK__.c[_16] = _24; ii_26 = ii_18 + 1; if (ii_18 == _7) goto <bb 6>; else goto <bb 9>; <bb 9>: goto <bb 8>; } ... the nit is _19: ... _20 = _6 + -1; _19 = (unsigned int) _20; ...