https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123636
--- Comment #7 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:e48704694d686de1aaaaf934c04a2eda1a6033cb commit r16-6900-ge48704694d686de1aaaaf934c04a2eda1a6033cb Author: Richard Biener <[email protected]> Date: Wed Jan 7 10:23:22 2026 +0100 tree-optimization/123061 - invalid hoisting of division The following fixes the computation of always-exeecuted-in in the LIM pass which was enhanced to handle inner loops in a better way but in this process ended up setting inner loop always-executed-in state based on outer loop analysis, which is wrong because an inner loop block needs to be proven to be always executed for all inner loop iterations as well, not only for all outer loop iterations. The fix is to iterate over inner loops first and when processing an outer loop only update always-executedness if a block belongs to the very same loop or an immediately nested loop and always executed inside that. PR tree-optimization/123061 PR tree-optimization/123636 * tree-ssa-loop-im.cc (fill_always_executed_in_1): Change outer-to-inner to inner-to-outer iteration. Update inner loop state only when always executed in an immediately nested loop. * gcc.dg/torture/pr123061.c: New testcase. * gcc.dg/torture/pr123636.c: Likewise. * gcc.dg/tree-ssa/ssa-lim-26.c: Likewise.
