]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/123061 - invalid hoisting of division
authorRichard Biener <rguenther@suse.de>
Wed, 7 Jan 2026 09:23:22 +0000 (10:23 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 19 Jan 2026 13:56:19 +0000 (14:56 +0100)
commite48704694d686de1aaaaf934c04a2eda1a6033cb
treeb1b8e6858980ca7a41e0e8bbfc60c9cf4aacf034
parent1367db23a5626499468d79b3c12a9b1859e7b819
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.
gcc/testsuite/gcc.dg/torture/pr123061.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr123636.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-26.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.cc