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 d568b08e3a48a307ed5967da8849a35aecbbc3df..25e539fbf323c0f37498a9cb36572a34d2c9fe62 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 53d7994897970769a38ba8098c9af96fd7165756..6c049d0f484f010716a967de25230c47affe66d2 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 a4d9a7194bf8a05b37b3612a5570b59de3b16a20..eae4b15b7f2c769a098c432348afa72dbec1ee56 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 22dd8015e9dd99177f582e03b805754ed4fa558b..2cc76d89bd4515a5889d09fc0a69ff6f03648bfd 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;