https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114052
--- Comment #20 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:2f37a08b51ef8022a2ef0b596006df65ceb44314 commit r13-9511-g2f37a08b51ef8022a2ef0b596006df65ceb44314 Author: Richard Biener <rguent...@suse.de> Date: Wed Jan 29 13:25:14 2025 +0100 tree-optimization/114052 - consider infinite sub-loops when lowering iter bound When we walk stmts to find always executed stmts with UB in the last iteration to be able to reduce the iteration count by one we fail to consider infinite subloops in the last iteration that would make such stmt not execute. The following adds this. PR tree-optimization/114052 * tree-ssa-loop-niter.cc (maybe_lower_iteration_bound): Check for infinite subloops we might not exit. * gcc.dg/pr114052-1.c: New testcase. (cherry picked from commit d1c7837d2d6e5a2997228681166ed8c814891881)