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 r11-9229] tree-optimization/102798 - avoid copying PTA info to old SSA names
Date: Mon,  8 Nov 2021 13:32:21 +0000 (GMT)	[thread overview]
Message-ID: <20211108133221.AAEEB385843F@sourceware.org> (raw)

https://gcc.gnu.org/g:1631d6d2910e03e4517079d6e6ad0ae1aeb24dfa

commit r11-9229-g1631d6d2910e03e4517079d6e6ad0ae1aeb24dfa
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Oct 18 09:10:43 2021 +0200

    tree-optimization/102798 - avoid copying PTA info to old SSA names
    
    The vectorizer duplicates pointer-info to created pointer bases
    but it has to avoid changing points-to info on existing SSA names
    because there's now flow-sensitive info in there (pt->pt_null as
    set from VRP).
    
    2021-10-18  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/102798
            * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
            Only copy points-to info to newly generated SSA names.
    
            * gcc.dg/pr102798.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/pr102798.c | 41 +++++++++++++++++++++++++++++++++++++++++
 gcc/tree-vect-data-refs.c       |  3 ++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr102798.c b/gcc/testsuite/gcc.dg/pr102798.c
new file mode 100644
index 00000000000..3a50546a16b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102798.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-tree-pta" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__((__noipa__))
+void BUF_reverse (unsigned char *out, const unsigned char *in, size_t size)
+{
+  size_t i;
+  if (in)
+    {
+      out += size - 1;
+      for (i = 0; i < size; i++)
+        *out++ = *in++;
+    }
+  else
+    {
+      unsigned char *q;
+      char c;
+      q = out + size - 1;
+      for (i = 0; i < size ; i++)
+            {
+              *out++ = 1;
+            }
+    }
+}
+
+int
+main (void)
+{
+  unsigned char buf[40];
+  unsigned char buf1[40];
+  for (unsigned i = 0; i < sizeof (buf); i++)
+    buf[i] = i;
+  BUF_reverse (buf, 0, sizeof (buf));
+  for (unsigned i = 0; i < sizeof (buf); i++)
+    if (buf[i] != 1)
+      __builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 23f4a7ef15f..e18afb2b657 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4701,7 +4701,8 @@ vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info,
 
   if (DR_PTR_INFO (dr)
       && TREE_CODE (addr_base) == SSA_NAME
-      && !SSA_NAME_PTR_INFO (addr_base))
+      /* We should only duplicate pointer info to newly created SSA names.  */
+      && SSA_NAME_VAR (addr_base) == dest)
     {
       vect_duplicate_ssa_name_ptr_info (addr_base, dr_info);
       if (offset || byte_offset)


                 reply	other threads:[~2021-11-08 13:32 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=20211108133221.AAEEB385843F@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).