https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129209
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:089e4a047bdb51f17701cab4049ff8111fd0ab75 commit r17-7064-g089e4a047bdb51f17701cab4049ff8111fd0ab75 Author: Richard Biener <[email protected]> Date: Wed Dec 2 13:56:02 2026 +0100 tree-optimization/129209 - NE_EXPR iteration bound when exit may not be taken number_of_iterations_ne_max divides the value range by the step even when it does not know that the NE_EXPR exit is taken. For a non-unit step the number of iterations is computed modulo the period of the control induction variable, so it can be as large as that period and the divided value is not a valid upper bound. IVOPTS uses this bound to check that a candidate induction variable does not run through a full period before an equality comparison is reached. With the too small bound it could replace a comparison of the control variable with a comparison of scaled values that are not injective, e.g. i == b by 4 * i == 4 * b, and exit the loop early. Use the period of the control induction variable as the bound when the exit is not known to be taken. PR tree-optimization/129209 * tree-ssa-loop-niter.cc (number_of_iterations_ne_max): Use the control IV period when the exit need not be taken. * gcc.dg/torture/pr129209.c: New test.
