From 6b68f00d4c2b375dad66bd6e72c01c309b4085c5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 19 Jul 2019 16:19:39 +0000 Subject: [PATCH] re PR tree-optimization/91211 (wrong code with __builtin_memset() and __builtin_memcpy() at -O1 and above) 2019-07-19 Richard Biener 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 | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr91211.c | 19 +++++++++++++++++++ gcc/tree-ssa-sccvn.c | 3 ++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr91211.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8824ffd..08f91ed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-07-19 Richard Biener + + PR tree-optimization/91211 + * tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Fix + memset encoding size. + 2019-07-19 Uroš Bizjak PR target/91204 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dfbf850..98fb40d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2019-07-19 Richard Biener + PR tree-optimization/91211 + * gcc.dg/torture/pr91211.c: New testcase. + +2019-07-19 Richard Biener + PR tree-optimization/91200 * gcc.dg/torture/pr91200.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/torture/pr91211.c b/gcc/testsuite/gcc.dg/torture/pr91211.c new file mode 100644 index 0000000..84db92d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91211.c @@ -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; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index f12c9dd..5b0460d 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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; -- 2.7.4