Commit 8afd015a by Jason Merrill Committed by Jason Merrill

gimplify.c (gimplify_init_constructor): Revert to using < rather than <= for sparseness test.

        * gimplify.c (gimplify_init_constructor): Revert to using < rather
        than <= for sparseness test.

From-SVN: r142618
parent 0889e9bc
...@@ -166,6 +166,9 @@ ...@@ -166,6 +166,9 @@
2008-12-09 Jason Merrill <jason@redhat.com> 2008-12-09 Jason Merrill <jason@redhat.com>
* gimplify.c (gimplify_init_constructor): Revert to using < rather
than <= for sparseness test.
PR c++/38410 PR c++/38410
* gimplify.c (gimplify_init_constructor): Don't write out a static * gimplify.c (gimplify_init_constructor): Don't write out a static
copy of the CONSTRUCTOR for TREE_ADDRESSABLE types or small sparse copy of the CONSTRUCTOR for TREE_ADDRESSABLE types or small sparse
...@@ -3502,7 +3502,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ...@@ -3502,7 +3502,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
struct gimplify_init_ctor_preeval_data preeval_data; struct gimplify_init_ctor_preeval_data preeval_data;
HOST_WIDE_INT num_type_elements, num_ctor_elements; HOST_WIDE_INT num_type_elements, num_ctor_elements;
HOST_WIDE_INT num_nonzero_elements; HOST_WIDE_INT num_nonzero_elements;
bool cleared, valid_const_initializer, sparse; bool cleared, valid_const_initializer;
/* Aggregate types must lower constructors to initialization of /* Aggregate types must lower constructors to initialization of
individual elements. The exception is that a CONSTRUCTOR node individual elements. The exception is that a CONSTRUCTOR node
...@@ -3558,9 +3558,6 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ...@@ -3558,9 +3558,6 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
num_type_elements = count_type_elements (type, true); num_type_elements = count_type_elements (type, true);
/* Are there significantly more zeros than non-zeros? */
sparse = (num_nonzero_elements <= num_type_elements/4);
/* If count_type_elements could not determine number of type elements /* If count_type_elements could not determine number of type elements
for a constant-sized object, assume clearing is needed. for a constant-sized object, assume clearing is needed.
Don't do this for variable-sized objects, as store_constructor Don't do this for variable-sized objects, as store_constructor
...@@ -3570,7 +3567,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ...@@ -3570,7 +3567,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
/* If there are "lots" of zeros, then block clear the object first. */ /* If there are "lots" of zeros, then block clear the object first. */
else if (num_type_elements - num_nonzero_elements else if (num_type_elements - num_nonzero_elements
> CLEAR_RATIO (optimize_function_for_speed_p (cfun)) > CLEAR_RATIO (optimize_function_for_speed_p (cfun))
&& sparse) && num_nonzero_elements < num_type_elements/4)
cleared = true; cleared = true;
/* ??? This bit ought not be needed. For any element not present /* ??? This bit ought not be needed. For any element not present
in the initializer, we should simply set them to zero. Except in the initializer, we should simply set them to zero. Except
...@@ -3585,9 +3582,12 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ...@@ -3585,9 +3582,12 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
be dropped to memory, and then memcpy'd out. Don't do this be dropped to memory, and then memcpy'd out. Don't do this
for sparse arrays, though, as it's more efficient to follow for sparse arrays, though, as it's more efficient to follow
the standard CONSTRUCTOR behavior of memset followed by the standard CONSTRUCTOR behavior of memset followed by
individual element initialization. Also don't try to do individual element initialization. Also don't do this for small
bitwise copies of TREE_ADDRESSABLE types. */ all-zero initializers (which aren't big enough to merit
if (valid_const_initializer && !(cleared || sparse) clearing), and don't try to make bitwise copies of
TREE_ADDRESSABLE types. */
if (valid_const_initializer
&& !(cleared || num_nonzero_elements == 0)
&& !TREE_ADDRESSABLE (type)) && !TREE_ADDRESSABLE (type))
{ {
HOST_WIDE_INT size = int_size_in_bytes (type); HOST_WIDE_INT size = int_size_in_bytes (type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment