https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125602
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2026-06-05
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Looks like a latent issue though:
/* {base, -C} < n. */
else if (tree_int_cst_sign_bit (iv0->step) && integer_zerop (iv1->step))
{
step = fold_build1 (NEGATE_EXPR, TREE_TYPE (iv0->step), iv0->step);
/* MAX - C + 1 >= n. */
tree last = wide_int_to_tree (type, max - wi::to_wide (step) + 1);
assumptions = fold_build2 (GE_EXPR, boolean_type_node, last, iv1->base);
if (integer_zerop (assumptions))
return false;
here step == -128 signed char. I recently fixed some other places like this,
but here we have to question correctness as well.
I'll note the "opposite" case does
/* n < {base, C}. */
if (integer_zerop (iv0->step) && !tree_int_cst_sign_bit (iv1->step))
{
step = iv1->step;
/* MIN + C - 1 <= n. */
tree last = wide_int_to_tree (type, min + wi::to_wide (step) - 1);
assumptions = fold_build2 (LE_EXPR, boolean_type_node, last, iv0->base);
so completely side-steps GENERIC folding with respect to overflow. Iff
that's OK there it should be OK in the other case as well ...(?)
Also, we're doing max - wi::to_wide (step) + 1, it's tempting to just
drop the negation and use max + wi::to_wide (step) + 1 ...
I'm testing that.