re PR tree-optimization/91091 ([missed optimization] Missing optimization in unaliase...
authorRichard Biener <rguenther@suse.de>
Fri, 5 Jul 2019 12:48:42 +0000 (12:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 5 Jul 2019 12:48:42 +0000 (12:48 +0000)
2019-07-05  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91091
* tree-ssa-sccvn.c (vn_reference_lookup_3): Overlap of
accesses can happen with -fno-strict-aliasing.

* gcc.dg/tree-ssa/pr91091-1.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-61.c: Adjust.

From-SVN: r273134

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-61.c
gcc/tree-ssa-sccvn.c

index d568b08..25e539f 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-05  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91091
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Overlap of
+       accesses can happen with -fno-strict-aliasing.
+
 2019-07-05  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-ssa-alias.c (alias_stats): Add
index 53d7994..6c049d0 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-05  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91091
+       * gcc.dg/tree-ssa/pr91091-1.c: New testcase.
+       * gcc.dg/tree-ssa/ssa-fre-61.c: Adjust.
+
 2019-07-05  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/pack23.adb, gnat.dg/pack23_pkg.ads: New testcase.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c
new file mode 100644 (file)
index 0000000..2ee75d9
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-strict-aliasing" } */
+
+struct s { int x; } __attribute__((packed));
+struct t { int x; };
+
+void __attribute__((noinline,noipa))
+swap(struct s* p, struct t* q)
+{
+  p->x = q->x;
+  q->x = p->x;
+}
+
+int main()
+{    
+  struct t a[2];
+  a[0].x = 0x12345678;
+  a[1].x = 0x98765432;
+  swap ((struct s *)((char *)a + 1), a);
+  if (a[0].x != 0x12345678)
+    __builtin_abort ();
+  return 0;
+}
index a4d9a71..eae4b15 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do link } */
-/* { dg-options "-O -fdump-tree-fre1-details" } */
+/* { dg-options "-O -fstrict-aliasing -fdump-tree-fre1-details" } */
 
 void link_error (void);
 
index 22dd801..2cc76d8 100644 (file)
@@ -1996,7 +1996,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
             activation of a union member via a store makes the
             values of untouched bytes unspecified.  */
          && (known_eq (ref->size, BITS_PER_UNIT)
-             || (get_alias_set (lhs) != 0
+             || (flag_strict_aliasing
+                 && get_alias_set (lhs) != 0
                  && ao_ref_alias_set (ref) != 0)))
        {
          tree *saved_last_vuse_ptr = data->last_vuse_ptr;