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 r12-9473] rtl-optimization/109585 - alias analysis typo
Date: Wed, 26 Apr 2023 10:41:20 +0000 (GMT)	[thread overview]
Message-ID: <20230426104120.B2CFD3857712@sourceware.org> (raw)

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

commit r12-9473-gef6051b36241bf130bf76af0b775248635dc616e
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Apr 24 13:31:07 2023 +0200

    rtl-optimization/109585 - alias analysis typo
    
    When r10-514-gc6b84edb6110dd2b4fb improved access path analysis
    it introduced a typo that triggers when there's an access to a
    trailing array in the first access path leading to false
    disambiguation.
    
            PR rtl-optimization/109585
            * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
    
            * gcc.dg/torture/pr109585.c: New testcase.
    
    (cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++++++++++
 gcc/tree-ssa-alias.cc                   |  2 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c
new file mode 100644
index 00000000000..f92de7c1f2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr109585.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+struct P {
+    long v;
+    struct P *n;
+};
+
+struct F {
+    long x;
+    struct P fam[];
+};
+
+int __attribute__((noipa))
+f(struct F *f, int i)
+{
+  struct P *p = f->fam;
+  asm("" : "+r"(f): "r"(p));
+  p->v = 0;
+  p->n = 0;
+  return f->fam->n != 0;
+}
+
+int
+main()
+{
+  struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P));
+  m->fam[0].n = &m->fam[1];
+  if (f (m, 0))
+    abort ();
+  return 0;
+}
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index b1e7a2d5afc..be7b597266f 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -1326,7 +1326,7 @@ aliasing_component_refs_p (tree ref1,
   /* If we didn't find a common base, try the other way around.  */
   if (cmp_outer <= 0 
       || (end_struct_ref1
-	  && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0))
+	  && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0))
     {
       int res = aliasing_component_refs_walk (ref2, type2, base2,
 					      offset2, max_size2,

                 reply	other threads:[~2023-04-26 10:41 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=20230426104120.B2CFD3857712@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).