aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-01-21 09:45:41 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-01-21 13:53:13 +0100
commit1d25e357c047f48cee50df318e965a0fbf84e2fe (patch)
treec1d244f6b83e3f6b28e492f1fe87b4359a977eca
parenteb0b551c5570d98dd7cf21fa1bd0240a0c9d875f (diff)
downloadgcc-1d25e357c047f48cee50df318e965a0fbf84e2fe.zip
gcc-1d25e357c047f48cee50df318e965a0fbf84e2fe.tar.gz
gcc-1d25e357c047f48cee50df318e965a0fbf84e2fe.tar.bz2
tree-optimization/118569 - LC SSA broken after unrolling
The following amends the previous fix to mark all of the loop BBs as need to be scanned for new LC PHI uses when its nesting parents changed, noticing one caller of fix_loop_placement was already doing that. So the following moves this code into fix_loop_placement, covering both callers now. PR tree-optimization/118569 * cfgloopmanip.cc (fix_loop_placement): When the loops nesting parents changed, mark all blocks to be scanned for LC PHI uses. (fix_bb_placements): Remove code moved into fix_loop_placement. * gcc.dg/torture/pr118569.c: New testcase.
-rw-r--r--gcc/cfgloopmanip.cc22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr118569.c36
2 files changed, 47 insertions, 11 deletions
diff --git a/gcc/cfgloopmanip.cc b/gcc/cfgloopmanip.cc
index 573146b..2c28437 100644
--- a/gcc/cfgloopmanip.cc
+++ b/gcc/cfgloopmanip.cc
@@ -154,10 +154,17 @@ fix_loop_placement (class loop *loop, bool *irred_invalidated,
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
*irred_invalidated = true;
rescan_loop_exit (e, false, false);
- /* Any LC SSA PHIs on e->dest might now be on the wrong edge
- if their defs were in a former outer loop. */
- if (loop_closed_ssa_invalidated)
- bitmap_set_bit (loop_closed_ssa_invalidated, e->src->index);
+ }
+ /* Any LC SSA PHIs on e->dest might now be on the wrong edge
+ if their defs were in a former outer loop. Also all uses
+ in the original inner loop of defs in the outer loop(s) now
+ require LC PHI nodes. */
+ if (loop_closed_ssa_invalidated)
+ {
+ basic_block *bbs = get_loop_body (loop);
+ for (unsigned i = 0; i < loop->num_nodes; ++i)
+ bitmap_set_bit (loop_closed_ssa_invalidated, bbs[i]->index);
+ free (bbs);
}
ret = true;
@@ -233,13 +240,6 @@ fix_bb_placements (basic_block from,
loop_closed_ssa_invalidated))
continue;
target_loop = loop_outer (from->loop_father);
- if (loop_closed_ssa_invalidated)
- {
- basic_block *bbs = get_loop_body (from->loop_father);
- for (unsigned i = 0; i < from->loop_father->num_nodes; ++i)
- bitmap_set_bit (loop_closed_ssa_invalidated, bbs[i]->index);
- free (bbs);
- }
}
else
{
diff --git a/gcc/testsuite/gcc.dg/torture/pr118569.c b/gcc/testsuite/gcc.dg/torture/pr118569.c
new file mode 100644
index 0000000..c5b404a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118569.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-ch -fno-tree-ccp -fno-tree-fre" } */
+
+volatile int a;
+int b, c, d, e, f, g;
+int main() {
+ int i = 2, j = 1;
+k:
+ if (!e)
+ ;
+ else {
+ short l = 1;
+ if (0)
+ m:
+ d = g;
+ f = 0;
+ for (; f < 2; f++) {
+ if (f)
+ for (; j < 2; j++)
+ if (i)
+ goto m;
+ a;
+ if (l)
+ continue;
+ i = 0;
+ while (c)
+ l++;
+ }
+ g = 0;
+ }
+ if (b) {
+ i = 1;
+ goto k;
+ }
+ return 0;
+}