re PR tree-optimization/91211 (wrong code with __builtin_memset() and __builtin_memcp...
authorRichard Biener <rguenther@suse.de>
Fri, 19 Jul 2019 16:19:39 +0000 (16:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 19 Jul 2019 16:19:39 +0000 (16:19 +0000)
2019-07-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91211
* tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Fix
memset encoding size.

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

From-SVN: r273605

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

index 8824ffd7b6f7db3991bdd2b68c3ca7b37063b1fd..08f91ed32db3e323c9f2564872263d2fe4ad9c02 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91211
+       * tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Fix
+       memset encoding size.
+
 2019-07-19  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/91204
index dfbf850b4fc1d5265aa0966fabb6f55e212c5bd6..98fb40ddd96a9bb4e26621e282cedd9967d56423 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91211
+       * gcc.dg/torture/pr91211.c: New testcase.
+
 2019-07-19  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/91200
diff --git a/gcc/testsuite/gcc.dg/torture/pr91211.c b/gcc/testsuite/gcc.dg/torture/pr91211.c
new file mode 100644 (file)
index 0000000..84db92d
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+typedef __UINT32_TYPE__ u32;
+
+int
+main (void)
+{
+  u32 b = 0x027C5902;
+  u32 a = 0;
+  __builtin_memset (1 + (char *) &b, 0, 2);
+  __builtin_memcpy (&a, 2 + (char *) &b, 2);
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+  if (a != 0x00000200)
+#else
+  if (a != 0x00020000)
+#endif
+    __builtin_abort();
+  return 0;
+}
index f12c9dd3403cb2da6ef6110a770ad2d4bccd0972..5b0460d2bc6319cbfa0c067574e1358d2a6cc116 100644 (file)
@@ -1818,7 +1818,8 @@ vn_walk_cb_data::push_partial_def (const pd_data &pd, tree vuse,
       if (TREE_CODE (pd.rhs) == CONSTRUCTOR)
        /* Empty CONSTRUCTOR.  */
        memset (buffer + MAX (0, pd.offset),
-               0, MIN ((HOST_WIDE_INT)sizeof (buffer), pd.size));
+               0, MIN ((HOST_WIDE_INT)sizeof (buffer),
+                       pd.size + MIN (0, pd.offset)));
       else
        {
          unsigned pad = 0;