https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128568
Oleg Endo <olegendo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |middle-end
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |olegendo at gcc dot gnu.org
Last reconfirmed| |2026-12-04
--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Confirmed. The expected program output should be "1 0 1", so neither is
correct.
The problem seems to be in:
gcc/loop-iv.cc:2701, iv_number_of_iterations rewrites the exit test i < n as a
<= b with b = n-1 and step s = 2. It then builds the "does not roll" condition
as a > b + s. With n = UINT_MAX, b + s = n+1 wraps to 0.
I haven't tried myself, but s390 and powerpc could be hitting the same issue.