https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123089

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |tnfchris at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #16 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Confirmed.

The IV overflows, the loop is known to iterate 8191 times and we have a VF of 8
and it starts at 2.

The codegen out of the vectorizer is the same as before, except we now have a
scalar variable counting the scalar iteration count vs a vector one.

i.e. we have

_45 = _39 + 8;

vs

_46 = _45 + { 16, 16, 16, 16, ... }

we pick a lower VF now since costing allows it to but that's not important.

When we get to cunroll since the value is now scalar, it sees that 8 * 8191
would overflow a signed int and so it changes the loop bounds to the largest
possible signed value and then uses this to elide the ivtmp_50 < 8191 as always
true and so you get an infinite loop:

Analyzing # of iterations of loop 1
  exit condition [1, + , 1](no_overflow) < 8191
  bounds on difference of bases: 8190 ... 8190
  result:
    # of iterations 8190, bounded by 8190
Statement (exit)if (ivtmp_50 < 8191)
 is executed at most 8190 (bounded by 8190) + 1 times in loop 1.
Induction variable (signed short) 8 + 8 * iteration does not wrap in statement
_45 = _39 + 8;
 in loop 1.
Statement _45 = _39 + 8;
 is executed at most 4094 (bounded by 4094) + 1 times in loop 1.

Testing a fix.

Reply via email to