public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-10105] tree-optimization/114832 - wrong dominator info with vect peeling
Date: Wed, 24 Apr 2024 08:13:02 +0000 (GMT)	[thread overview]
Message-ID: <20240424081304.00B3A385840D@sourceware.org> (raw)

https://gcc.gnu.org/g:e28e8ab1a92e9b49f7c4045377577c8dc17751b7

commit r14-10105-ge28e8ab1a92e9b49f7c4045377577c8dc17751b7
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Apr 24 06:24:22 2024 +0200

    tree-optimization/114832 - wrong dominator info with vect peeling
    
    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.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114832.c | 13 +++++++++++++
 gcc/tree-vect-loop-manip.cc          |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

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

                 reply	other threads:[~2024-04-24  8:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424081304.00B3A385840D@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).