re PR tree-optimization/91180 (wrong code at -O and above with __builtin_memset())
authorRichard Biener <rguenther@suse.de>
Wed, 17 Jul 2019 09:35:04 +0000 (09:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 17 Jul 2019 09:35:04 +0000 (09:35 +0000)
2019-07-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91180
* tree-ssa-sccvn.c (vn_reference_lookup_3): Fix offset
computation for memset partial defs.

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

From-SVN: r273548

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

index 0c1c133d0ad3a378e28ad28f5df7730035fe8a66..877de1982b86e864499605e0694cb930af88c30f 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91180
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Fix offset
+       computation for memset partial defs.
+
 2019-07-17  Jakub Jelinek  <jakub@redhat.com>
 
        * gimple.h (enum gf_mask): Remove GF_OMP_FOR_SIMD, change
index 5c156c7738f399f4aec616e5a8f1a44f8e514447..f9ee4825f17b80cc379a8bfda528aa8282760461 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91180
+       * gcc.dg/torture/pr91180.c: New testcase.
+
 2019-07-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/91157
diff --git a/gcc/testsuite/gcc.dg/torture/pr91180.c b/gcc/testsuite/gcc.dg/torture/pr91180.c
new file mode 100644 (file)
index 0000000..02b2425
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+
+int
+main ()
+{
+#if __SIZEOF_INT__ == 4
+  unsigned x = 0xffffffff;
+  __builtin_memset (1 + (char *) &x, 0, 2);
+  if (x != 0xff0000ff)
+    __builtin_abort ();
+#endif
+  return 0;
+}
index 73c77d1df4b24e92f528f088e8fa4a62a6300082..830d37b86bb0ecb8ba55e45597fcb80ddf743e3c 100644 (file)
@@ -2486,7 +2486,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
        {
          pd_data pd;
          pd.rhs = build_constructor (NULL_TREE, NULL);
-         pd.offset = offset2i - offseti;
+         pd.offset = (offset2i - offseti) / BITS_PER_UNIT;
          pd.size = leni;
          return data->push_partial_def (pd, vuse, maxsizei);
        }