The following fixes PR91180.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2019-07-17  Richard Biener  <rguent...@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.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c        (revision 273542)
+++ gcc/tree-ssa-sccvn.c        (working copy)
@@ -2486,7 +2535,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree
        {
          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);
        }
Index: gcc/testsuite/gcc.dg/torture/pr91180.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr91180.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr91180.c      (working copy)
@@ -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;
+}

Reply via email to