http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55555
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-14 14:11:59 UTC --- The unrolling puts __builtin_unreachable ()s into the inner duplicated loops: First iteration, good: <bb 16>: # lxp_30 = PHI <0(2)> t_32 = pol_x[lxp_30]; _33 = (long int) lxp_30; _34 = _33 * 4; l_35 = _34 + -1; <bb 17>: # S_36 = PHI <1(16), S_45(18)> if (S_36 <= 4) goto <bb 18>; else goto <bb 19>; <bb 18>: _38 = S_36 + l_35; _39 = coef_x[_38]; _40 = S_36 + -1; _41 = s[_40]; _42 = _41 * t_32; _43 = _39 + _42; coef_x[_38] = _43; S_45 = S_36 + 1; goto <bb 17>; <bb 19>: lxp_46 = lxp_30 + 1; <bb 20>: Peeled iteration, bad: <bb 3>: # lxp_1 = PHI <lxp_46(20)> t_9 = pol_x[lxp_1]; _10 = (long int) lxp_1; _11 = _10 * 4; l_12 = _11 + -1; goto <bb 5>; <bb 4>: _13 = S_3 + l_12; __builtin_unreachable (); _14 = coef_x[_13]; _15 = S_3 + -1; _16 = s[_15]; _17 = _16 * t_9; _18 = _14 + _17; __builtin_unreachable (); coef_x[_13] = _18; S_20 = S_3 + 1; <bb 5>: # S_3 = PHI <1(3), S_20(4)> if (S_3 <= 4) goto <bb 4>; else goto <bb 6>; <bb 6>: lxp_21 = lxp_1 + 1; if (1 == 0) goto <bb 15>; else goto <bb 7>; <bb 15>: <bb 22>: __builtin_unreachable (); <bb 7>: __asm__ __volatile__("" : : "r" &coef_x : "memory"); goto <bb 13>; Note that the outer loop body looks ok - it is the inner body that get's mangled in a bogus way. That's because the loop bounds derived from the inner loop accesses are bogus: remove_exits_and_undefined_stmts (loop=0x7ffff67ec770, npeeled=1) at /space/rguenther/src/svn/trunk/gcc/tree-ssa-loop-ivcanon.c:481 481 bool changed = false; (gdb) n 483 for (elt = loop->bounds; elt; elt = elt->next) (gdb) 488 if (!elt->is_exit (gdb) p elt $8 = (nb_iter_bound *) 0x7ffff6925e38 (gdb) p *elt $9 = {stmt = 0x7ffff6905c80, bound = {low = 0, high = 0}, is_exit = false, next = 0x7ffff6925dc0} (gdb) p elt->stmt $10 = (gimple) 0x7ffff6905c80 (gdb) call debug_gimple_stmt ($10) # .MEM_19 = VDEF <.MEM_6> coef_x[_13] = _18; as far as I can see even with lxp == 1 we have at most an index of 4 + 1*4 - 1. Statement _14 = coef_x[_13]; is executed at most 0 (bounded by 0) + 1 times in loop 1. _that's_ bogus.