From 9505acd8501e6c79bc4fa9ed9f1ee174462601d1 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 17 Jul 2019 09:35:04 +0000 Subject: [PATCH] re PR tree-optimization/91180 (wrong code at -O and above with __builtin_memset()) 2019-07-17 Richard Biener 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. From-SVN: r273548 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr91180.c | 13 +++++++++++++ gcc/tree-ssa-sccvn.c | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr91180.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c1c133d0ad..877de1982b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-07-17 Richard Biener + + PR tree-optimization/91180 + * tree-ssa-sccvn.c (vn_reference_lookup_3): Fix offset + computation for memset partial defs. + 2019-07-17 Jakub Jelinek * gimple.h (enum gf_mask): Remove GF_OMP_FOR_SIMD, change diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c156c7738f..f9ee4825f17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-17 Richard Biener + + PR tree-optimization/91180 + * gcc.dg/torture/pr91180.c: New testcase. + 2019-07-17 Jakub Jelinek PR tree-optimization/91157 diff --git a/gcc/testsuite/gcc.dg/torture/pr91180.c b/gcc/testsuite/gcc.dg/torture/pr91180.c new file mode 100644 index 00000000000..02b2425126e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91180.c @@ -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; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 73c77d1df4b..830d37b86bb 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2486,7 +2486,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, { 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); } -- 2.30.2