From: Richard Biener Date: Fri, 19 Jul 2019 16:19:39 +0000 (+0000) Subject: re PR tree-optimization/91211 (wrong code with __builtin_memset() and __builtin_memcp... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6b68f00d4c2b375dad66bd6e72c01c309b4085c5;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8824ffd7b6f..08f91ed32db 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 dfbf850b4fc..98fb40ddd96 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gcc/testsuite/gcc.dg/torture/pr91211.c b/gcc/testsuite/gcc.dg/torture/pr91211.c new file mode 100644 index 00000000000..84db92dd6be --- /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 f12c9dd3403..5b0460d2bc6 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;