Fix PR91211
diff mbox series

Message ID alpine.LSU.2.20.1907191425400.30921@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR91211
Related show

Commit Message

Richard Biener July 19, 2019, 12:26 p.m. UTC
Another issue in partial-def VN.

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

Richard.

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.

Patch
diff mbox series

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	(revision 273592)
+++ gcc/tree-ssa-sccvn.c	(working copy)
@@ -1818,7 +1818,8 @@  vn_walk_cb_data::push_partial_def (const
       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;
Index: gcc/testsuite/gcc.dg/torture/pr91211.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr91211.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr91211.c	(working copy)
@@ -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;
+}