public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/114832 - wrong dominator info with vect peeling
@ 2024-04-24  4:43 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-04-24  4:43 UTC (permalink / raw)
  To: gcc-patches

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.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

 	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 | 13 +++++++++++++
  gcc/tree-vect-loop-manip.cc          |  2 +-
  2 files changed, 14 insertions(+), 1 deletion(-)
  create mode 100644 gcc/testsuite/gcc.dg/vect/pr114832.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr114832.c b/gcc/testsuite/gcc.dg/vect/pr114832.c
new file mode 100644
index 00000000000..2de07ae22ef
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114832.c
@@ -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;
+  }
+}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 8d9b533d50f..43c7881c640 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -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
-- 
2.25.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-24  4:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24  4:43 [PATCH] tree-optimization/114832 - wrong dominator info with vect peeling Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).