re PR tree-optimization/86363 (wrong code with __builtin_memset() at -O1)
authorRichard Biener <rguenther@suse.de>
Mon, 2 Jul 2018 13:32:26 +0000 (13:32 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 2 Jul 2018 13:32:26 +0000 (13:32 +0000)
2018-07-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86363
* tree-ssa-sccvn.c (vn_reference_lookup_3): Check the
memset argument refers to a non-variable address.

* gcc.dg/torture/pr86363.c: New testcase.

From-SVN: r262307

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr86363.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 15f2749d49242716fcddb80aed4de1542cda2bee..dc90e39d0789454724b9ca86c02f0ad668ed9a91 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86363
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Check the
+       memset argument refers to a non-variable address.
+
 2018-07-02  Aldy Hernandez  <aldyh@redhat.com>
 
        * tree-vrp.c (extract_range_from_binary_expr_1): Abstract a lot of the
index cc94d3bf740ed8f38f178c1a75581623ee242ba1..8b091305b955725845566af850a6cd178654369a 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86363
+       * gcc.dg/torture/pr86363.c: New testcase.
+
 2018-07-02  Martin Liska  <mliska@suse.cz>
 
        * gcc.dg/completion-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr86363.c b/gcc/testsuite/gcc.dg/torture/pr86363.c
new file mode 100644 (file)
index 0000000..154f938
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+typedef char U __attribute__ ((vector_size (16)));
+typedef unsigned V __attribute__ ((vector_size (16)));
+
+V g;
+
+V
+f (V v, U u)
+{
+  __builtin_memset (&u[v[0]], 0, 1);
+  g ^= u[0];
+  return g;
+}
+
+int
+main (void)
+{
+  V x = f ((V) { 5 }, (U) { 1 });
+
+  if (x[0] != 1 || x[1] != 1 || x[2] != 1 || x[3] != 1)
+    __builtin_abort ();
+  return 0;
+}
index e5eddf902b84ac864e239c6846af71e12d4b7cab..1e16e13cfa16d909c88cd2e0d703cff2c6d6797b 100644 (file)
@@ -1988,6 +1988,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
          base2 = get_ref_base_and_extent (ref2, &offset2, &size2, &maxsize2,
                                           &reverse);
          if (!known_size_p (maxsize2)
+             || !known_eq (maxsize2, size2)
              || !operand_equal_p (base, base2, OEP_ADDRESS_OF))
            return (void *)-1;
        }