From f1bf4f3afb21fdb807c050693ac9da523e64f2a4 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 4 Apr 2013 10:55:25 +0000 Subject: [PATCH] re PR tree-optimization/56837 (-ftree-loop-distribute-patterns generates incorrect code) 2013-04-04 Richard Biener PR tree-optimization/56837 * tree-loop-distribution.c (classify_partition): For non-zero values require that the value has the same precision as its mode to be useful as memset value. * g++.dg/torture/pr56837.C: New testcase. From-SVN: r197476 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr56837.C | 20 ++++++++++++++++++++ gcc/tree-loop-distribution.c | 12 ++++++++---- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr56837.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 26e7f08646e..8c281007632 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2013-04-04 Richard Biener + + PR tree-optimization/56837 + * tree-loop-distribution.c (classify_partition): For non-zero + values require that the value has the same precision as its + mode to be useful as memset value. + 2013-04-03 Nick Clifton * config/v850/v850e3v5.md (fmasf4): Use fmaf.s on E3V5 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6596dce007c..a8ecc418f46 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-04 Richard Biener + + PR tree-optimization/56837 + * g++.dg/torture/pr56837.C: New testcase. + 2013-04-04 Tobias Burnus PR fortran/50269 diff --git a/gcc/testsuite/g++.dg/torture/pr56837.C b/gcc/testsuite/g++.dg/torture/pr56837.C new file mode 100644 index 00000000000..d0071228047 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr56837.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-ftree-loop-distribute-patterns" } + +extern "C" void abort (void); +extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__); + +bool b1[8]; +bool b2[8] = { true, true, true, true, true, true, true, true }; + +int main() +{ + unsigned int i; + for(i=0 ; i < 8; i++) + b1[i] = true; + + if (memcmp (b1, b2, 8) != 0) + abort (); + + return 0; +} diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 70f71b37c83..101efbed0a5 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -942,13 +942,17 @@ classify_partition (loop_p loop, struct graph *rdg, partition_t partition) gimple stmt = DR_STMT (single_store); tree rhs = gimple_assign_rhs1 (stmt); if (!(integer_zerop (rhs) - || integer_all_onesp (rhs) || real_zerop (rhs) || (TREE_CODE (rhs) == CONSTRUCTOR && !TREE_CLOBBER_P (rhs)) - || (INTEGRAL_TYPE_P (TREE_TYPE (rhs)) - && (TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))) - == TYPE_MODE (unsigned_char_type_node))))) + || ((integer_all_onesp (rhs) + || (INTEGRAL_TYPE_P (TREE_TYPE (rhs)) + && (TYPE_MODE (TREE_TYPE (rhs)) + == TYPE_MODE (unsigned_char_type_node)))) + /* For stores of a non-zero value require that the precision + of the value matches its actual size. */ + && (TYPE_PRECISION (TREE_TYPE (rhs)) + == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs))))))) return; if (TREE_CODE (rhs) == SSA_NAME && !SSA_NAME_IS_DEFAULT_DEF (rhs)