Commit 460f84ed by Richard Henderson Committed by Richard Henderson

re PR middle-end/21529 (code size regression (+40%) with -Os from GCC-3.4.3 to 4.1)

        PR 21529
        * params.def (PARAM_SRA_MAX_STRUCTURE_COUNT): New.
        * params.h (SRA_MAX_STRUCTURE_COUNT): New.
        * tree-sra.c (decide_block_copy): Use it.  Disable element copy
        if we'd have to instantiate too many members.

From-SVN: r102761
parent ea78022d
2005-08-04 Richard Henderson <rth@redhat.com> 2005-08-04 Richard Henderson <rth@redhat.com>
PR 21529
* params.def (PARAM_SRA_MAX_STRUCTURE_COUNT): New.
* params.h (SRA_MAX_STRUCTURE_COUNT): New.
* tree-sra.c (decide_block_copy): Use it. Disable element copy
if we'd have to instantiate too many members.
2005-08-04 Richard Henderson <rth@redhat.com>
PR 21291 PR 21291
* tree-outof-ssa.c (coalesce_asm_operands): New. * tree-outof-ssa.c (coalesce_asm_operands): New.
(coalesce_ssa_name): Use it. Split out ... (coalesce_ssa_name): Use it. Split out ...
......
...@@ -54,14 +54,25 @@ DEFPARAM (PARAM_SALIAS_MAX_IMPLICIT_FIELDS, ...@@ -54,14 +54,25 @@ DEFPARAM (PARAM_SALIAS_MAX_IMPLICIT_FIELDS,
itself. */ itself. */
DEFPARAM (PARAM_SRA_MAX_STRUCTURE_SIZE, DEFPARAM (PARAM_SRA_MAX_STRUCTURE_SIZE,
"sra-max-structure-size", "sra-max-structure-size",
"The maximum structure size (in bytes) at which GCC will do block copies", "The maximum structure size (in bytes) for which GCC will "
"use by-element copies",
0, 0, 0)
/* The maximum number of structure fields which the SRA pass will
instantiate to avoid block copies. The default value, 0, implies
that GCC will select the appropriate value itself. */
DEFPARAM (PARAM_SRA_MAX_STRUCTURE_COUNT,
"sra-max-structure-count",
"The maximum number of structure fields for which GCC will "
"use by-element copies",
0, 0, 0) 0, 0, 0)
/* The ratio between instantiated fields and the complete structure /* The ratio between instantiated fields and the complete structure
size. We say that if the ratio of the number of bytes in size. We say that if the ratio of the number of bytes in
instantiated fields to the number of bytes in the complete instantiated fields to the number of bytes in the complete
structure exceeds this parameter, then block copies are not used. structure exceeds this parameter, or if the number of instantiated
The default is 75%. */ fields to the total number of fields exceeds this parameter, then
block copies are not used. The default is 75%. */
DEFPARAM (PARAM_SRA_FIELD_STRUCTURE_RATIO, DEFPARAM (PARAM_SRA_FIELD_STRUCTURE_RATIO,
"sra-field-structure-ratio", "sra-field-structure-ratio",
"The threshold ratio between instantiated fields and the total structure size", "The threshold ratio between instantiated fields and the total structure size",
......
...@@ -93,6 +93,8 @@ typedef enum compiler_param ...@@ -93,6 +93,8 @@ typedef enum compiler_param
PARAM_VALUE (PARAM_SALIAS_MAX_IMPLICIT_FIELDS) PARAM_VALUE (PARAM_SALIAS_MAX_IMPLICIT_FIELDS)
#define SRA_MAX_STRUCTURE_SIZE \ #define SRA_MAX_STRUCTURE_SIZE \
PARAM_VALUE (PARAM_SRA_MAX_STRUCTURE_SIZE) PARAM_VALUE (PARAM_SRA_MAX_STRUCTURE_SIZE)
#define SRA_MAX_STRUCTURE_COUNT \
PARAM_VALUE (PARAM_SRA_MAX_STRUCTURE_COUNT)
#define SRA_FIELD_STRUCTURE_RATIO \ #define SRA_FIELD_STRUCTURE_RATIO \
PARAM_VALUE (PARAM_SRA_FIELD_STRUCTURE_RATIO) PARAM_VALUE (PARAM_SRA_FIELD_STRUCTURE_RATIO)
#define MAX_INLINE_INSNS_SINGLE \ #define MAX_INLINE_INSNS_SINGLE \
......
...@@ -1325,7 +1325,7 @@ decide_block_copy (struct sra_elt *elt) ...@@ -1325,7 +1325,7 @@ decide_block_copy (struct sra_elt *elt)
else if (host_integerp (size_tree, 1)) else if (host_integerp (size_tree, 1))
{ {
unsigned HOST_WIDE_INT full_size, inst_size = 0; unsigned HOST_WIDE_INT full_size, inst_size = 0;
unsigned int max_size; unsigned int max_size, max_count, inst_count, full_count;
/* If the sra-max-structure-size parameter is 0, then the /* If the sra-max-structure-size parameter is 0, then the
user has not overridden the parameter and we can choose a user has not overridden the parameter and we can choose a
...@@ -1333,8 +1333,13 @@ decide_block_copy (struct sra_elt *elt) ...@@ -1333,8 +1333,13 @@ decide_block_copy (struct sra_elt *elt)
max_size = SRA_MAX_STRUCTURE_SIZE max_size = SRA_MAX_STRUCTURE_SIZE
? SRA_MAX_STRUCTURE_SIZE ? SRA_MAX_STRUCTURE_SIZE
: MOVE_RATIO * UNITS_PER_WORD; : MOVE_RATIO * UNITS_PER_WORD;
max_count = SRA_MAX_STRUCTURE_COUNT
? SRA_MAX_STRUCTURE_COUNT
: MOVE_RATIO;
full_size = tree_low_cst (size_tree, 1); full_size = tree_low_cst (size_tree, 1);
full_count = count_type_elements (elt->type);
inst_count = sum_instantiated_sizes (elt, &inst_size);
/* ??? What to do here. If there are two fields, and we've only /* ??? What to do here. If there are two fields, and we've only
instantiated one, then instantiating the other is clearly a win. instantiated one, then instantiating the other is clearly a win.
...@@ -1344,15 +1349,12 @@ decide_block_copy (struct sra_elt *elt) ...@@ -1344,15 +1349,12 @@ decide_block_copy (struct sra_elt *elt)
/* If the structure is small, and we've made copies, go ahead /* If the structure is small, and we've made copies, go ahead
and instantiate, hoping that the copies will go away. */ and instantiate, hoping that the copies will go away. */
if (full_size <= max_size if (full_size <= max_size
&& (full_count - inst_count) <= max_count
&& elt->n_copies > elt->n_uses) && elt->n_copies > elt->n_uses)
use_block_copy = false; use_block_copy = false;
else else if (inst_count * 100 >= full_count * SRA_FIELD_STRUCTURE_RATIO
{ && inst_size * 100 >= full_size * SRA_FIELD_STRUCTURE_RATIO)
sum_instantiated_sizes (elt, &inst_size); use_block_copy = false;
if (inst_size * 100 >= full_size * SRA_FIELD_STRUCTURE_RATIO)
use_block_copy = false;
}
/* In order to avoid block copy, we have to be able to instantiate /* In order to avoid block copy, we have to be able to instantiate
all elements of the type. See if this is possible. */ all elements of the type. See if this is possible. */
......
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