]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114832 - wrong dominator info with vect peeling
authorRichard Biener <rguenther@suse.de>
Wed, 24 Apr 2024 04:24:22 +0000 (06:24 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 24 Apr 2024 08:11:00 +0000 (10:11 +0200)
When we update the dominator of the redirected exit after peeling
we check whether the immediate dominator was the loop header rather
than the exit source when we later want to just update it to the
new source.  The following fixes this oversight.

PR tree-optimization/114832
* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
Fix dominance check.

* gcc.dg/vect/pr114832.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr114832.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr114832.c b/gcc/testsuite/gcc.dg/vect/pr114832.c
new file mode 100644 (file)
index 0000000..2de07ae
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-loop-if-convert -fno-tree-loop-distribute-patterns" } */
+
+int a, b, c, d[3];
+void e() {
+  int f, g = 0;
+  for (; g < 3; g++) {
+    if (f || a || b && c) {
+      int h, *i = &h, **j = &i;
+    }
+    d[g] = 0;
+  }
+}
index 8d9b533d50fca3667c8908af621b64a40ae2f0f5..43c7881c640df45a81314d82d231680cf9e9843a 100644 (file)
@@ -1523,7 +1523,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit,
 
   exit_dest = exit->dest;
   was_imm_dom = (get_immediate_dominator (CDI_DOMINATORS,
-                                         exit_dest) == loop->header ?
+                                         exit_dest) == exit->src ?
                 true : false);
 
   /* Also copy the pre-header, this avoids jumping through hoops to