diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-09 06:04:50 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-09 06:04:50 +0000 |
commit | 352649dc55bb53249b99368de7cf114fe436a32b (patch) | |
tree | 3f57073523259bbf324791a19922b2e0b03088dd /gcc/gimplify.c | |
parent | 6af35ce55b6642bc88c58e539ced2c27cdfca3e4 (diff) | |
download | gcc-352649dc55bb53249b99368de7cf114fe436a32b.tar.gz |
PR c++/38410
* gimplify.c (gimplify_init_constructor): Don't write out a static
copy of the CONSTRUCTOR for TREE_ADDRESSABLE types or small sparse
initializers.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142580 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2fea882811f..01b2fbef6b7 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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; HOST_WIDE_INT num_type_elements, num_ctor_elements; HOST_WIDE_INT num_nonzero_elements; - bool cleared, valid_const_initializer; + bool cleared, valid_const_initializer, sparse; /* Aggregate types must lower constructors to initialization of individual elements. The exception is that a CONSTRUCTOR node @@ -3558,6 +3558,9 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, 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 for a constant-sized object, assume clearing is needed. Don't do this for variable-sized objects, as store_constructor @@ -3567,7 +3570,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. */ else if (num_type_elements - num_nonzero_elements > CLEAR_RATIO (optimize_function_for_speed_p (cfun)) - && num_nonzero_elements < num_type_elements/4) + && sparse) cleared = true; /* ??? This bit ought not be needed. For any element not present in the initializer, we should simply set them to zero. Except @@ -3582,8 +3585,10 @@ 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 for sparse arrays, though, as it's more efficient to follow the standard CONSTRUCTOR behavior of memset followed by - individual element initialization. */ - if (valid_const_initializer && !cleared) + individual element initialization. Also don't try to do + bitwise copies of TREE_ADDRESSABLE types. */ + if (valid_const_initializer && !(cleared || sparse) + && !TREE_ADDRESSABLE (type)) { HOST_WIDE_INT size = int_size_in_bytes (type); unsigned int align; |