This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR56837
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 4 Apr 2013 12:47:50 +0200 (CEST)
- Subject: [PATCH] Fix PR56837
This fixes PR56837, memset recognition should verify that constants
really cover all of their representation. Esp. all-ones ones.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2013-04-04 Richard Biener <rguenther@suse.de>
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.
Index: gcc/tree-loop-distribution.c
===================================================================
*** gcc/tree-loop-distribution.c (revision 197414)
--- gcc/tree-loop-distribution.c (working copy)
*************** classify_partition (loop_p loop, struct
*** 942,954 ****
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)))))
return;
if (TREE_CODE (rhs) == SSA_NAME
&& !SSA_NAME_IS_DEFAULT_DEF (rhs)
--- 942,958 ----
gimple stmt = DR_STMT (single_store);
tree rhs = gimple_assign_rhs1 (stmt);
if (!(integer_zerop (rhs)
|| real_zerop (rhs)
|| (TREE_CODE (rhs) == CONSTRUCTOR
&& !TREE_CLOBBER_P (rhs))
! || ((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)
Index: gcc/testsuite/g++.dg/torture/pr56837.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr56837.C (revision 0)
--- gcc/testsuite/g++.dg/torture/pr56837.C (working copy)
***************
*** 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;
+ }