re PR middle-end/21478 (Improve initialization of sparse local arrays)
PR 21478 * gimplify.c (gimplify_init_constructor): Don't spill initializer to read-only memory if it's sparse. From-SVN: r100465
This commit is contained in:
parent
03569a4047
commit
cce7074710
|
@ -1,3 +1,9 @@
|
||||||
|
2005-06-01 Josh Conner <jconner@apple.com>
|
||||||
|
|
||||||
|
PR 21478
|
||||||
|
* gimplify.c (gimplify_init_constructor): Don't spill initializer
|
||||||
|
to read-only memory if it's sparse.
|
||||||
|
|
||||||
2005-06-01 Ramana Radhakrishnan <ramana@codito.com>
|
2005-06-01 Ramana Radhakrishnan <ramana@codito.com>
|
||||||
|
|
||||||
* doc/rtl.texi: Remove references to NOTE_INSN_SETJMP.
|
* doc/rtl.texi: Remove references to NOTE_INSN_SETJMP.
|
||||||
|
|
|
@ -2649,10 +2649,35 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there are "lots" of initialized elements, even discounting
|
||||||
|
those that are not address constants (and thus *must* be
|
||||||
|
computed at runtime), then partition the constructor into
|
||||||
|
constant and non-constant parts. Block copy the constant
|
||||||
|
parts in, then generate code for the non-constant parts. */
|
||||||
|
/* TODO. There's code in cp/typeck.c to do this. */
|
||||||
|
|
||||||
|
num_type_elements = count_type_elements (TREE_TYPE (ctor));
|
||||||
|
|
||||||
|
/* If there are "lots" of zeros, then block clear the object first. */
|
||||||
|
if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
|
||||||
|
&& num_nonzero_elements < num_type_elements/4)
|
||||||
|
cleared = true;
|
||||||
|
|
||||||
|
/* ??? This bit ought not be needed. For any element not present
|
||||||
|
in the initializer, we should simply set them to zero. Except
|
||||||
|
we'd need to *find* the elements that are not present, and that
|
||||||
|
requires trickery to avoid quadratic compile-time behavior in
|
||||||
|
large cases or excessive memory use in small cases. */
|
||||||
|
else if (num_ctor_elements < num_type_elements)
|
||||||
|
cleared = true;
|
||||||
|
|
||||||
/* If there are "lots" of initialized elements, and all of them
|
/* If there are "lots" of initialized elements, and all of them
|
||||||
are valid address constants, then the entire initializer can
|
are valid address constants, then the entire initializer can
|
||||||
be dropped to memory, and then memcpy'd out. */
|
be dropped to memory, and then memcpy'd out. Don't do this
|
||||||
if (num_nonconstant_elements == 0)
|
for sparse arrays, though, as it's more efficient to follow
|
||||||
|
the standard CONSTRUCTOR behavior of memset followed by
|
||||||
|
individual element initialization. */
|
||||||
|
if (num_nonconstant_elements == 0 && !cleared)
|
||||||
{
|
{
|
||||||
HOST_WIDE_INT size = int_size_in_bytes (type);
|
HOST_WIDE_INT size = int_size_in_bytes (type);
|
||||||
unsigned int align;
|
unsigned int align;
|
||||||
|
@ -2698,28 +2723,6 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there are "lots" of initialized elements, even discounting
|
|
||||||
those that are not address constants (and thus *must* be
|
|
||||||
computed at runtime), then partition the constructor into
|
|
||||||
constant and non-constant parts. Block copy the constant
|
|
||||||
parts in, then generate code for the non-constant parts. */
|
|
||||||
/* TODO. There's code in cp/typeck.c to do this. */
|
|
||||||
|
|
||||||
num_type_elements = count_type_elements (TREE_TYPE (ctor));
|
|
||||||
|
|
||||||
/* If there are "lots" of zeros, then block clear the object first. */
|
|
||||||
if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
|
|
||||||
&& num_nonzero_elements < num_type_elements/4)
|
|
||||||
cleared = true;
|
|
||||||
|
|
||||||
/* ??? This bit ought not be needed. For any element not present
|
|
||||||
in the initializer, we should simply set them to zero. Except
|
|
||||||
we'd need to *find* the elements that are not present, and that
|
|
||||||
requires trickery to avoid quadratic compile-time behavior in
|
|
||||||
large cases or excessive memory use in small cases. */
|
|
||||||
else if (num_ctor_elements < num_type_elements)
|
|
||||||
cleared = true;
|
|
||||||
|
|
||||||
if (cleared)
|
if (cleared)
|
||||||
{
|
{
|
||||||
/* Zap the CONSTRUCTOR element list, which simplifies this case.
|
/* Zap the CONSTRUCTOR element list, which simplifies this case.
|
||||||
|
|
Loading…
Reference in New Issue