https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121382
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:5d55cd95e2bbb1114a59ca743671188634e757cc commit r16-2782-g5d55cd95e2bbb1114a59ca743671188634e757cc Author: Richard Biener <rguent...@suse.de> Date: Tue Aug 5 10:38:03 2025 +0200 tree-optimization/121382 - avoid UB in IVOPTs inserted step computation IVOPTs, when replacing an IV, inserts the computation of the new IVs step in the loop preheader without considering the case of the loop not iterating. This means we have to ensure the step computation does not invoke UB. There is also SCEV which does not care about signed arithmetic UB when re-associating expressions to form CHRECs, so even when we know the loop iterates this is required. PR tree-optimization/121382 * tree-ssa-loop-ivopts.cc (create_new_iv): Rewrite the IV step to defined form. * gcc.dg/torture/pr121382.c: New testcase.