From 5a6bc9c7188163b20276d6dd80c7c76165fdf9c2 Mon Sep 17 00:00:00 2001 From: James Greenhalgh Date: Thu, 6 Nov 2014 14:18:52 +0000 Subject: [Patchv3] Control SRA and IPA-SRA by a param rather than MOVE_RATIO gcc/ * params.def (sra-max-scalarization-size-Ospeed): New. (sra-max-scalarization-size-Osize): Likewise. * doc/invoke.texi (sra-max-scalarization-size-Ospeed): Document. (sra-max-scalarization-size-Osize): Likewise. * toplev.c (process_options): Set default values for new parameters. * tree-sra.c (analyze_all_variable_accesses): Use new parameters. * targhooks.c (get_move_ratio): Remove static designator. * target.h (get_move_ratio): Declare. From-SVN: r217191 --- gcc/ChangeLog | 12 ++++++++++++ gcc/doc/invoke.texi | 10 ++++++++++ gcc/params.def | 12 ++++++++++++ gcc/target.h | 4 ++++ gcc/targhooks.c | 2 +- gcc/toplev.c | 14 ++++++++++++++ gcc/tree-sra.c | 12 +++++++----- 7 files changed, 60 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f362e2e..dafb268 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2014-11-06 James Greenhalgh + + * params.def (sra-max-scalarization-size-Ospeed): New. + (sra-max-scalarization-size-Osize): Likewise. + * doc/invoke.texi (sra-max-scalarization-size-Ospeed): Document. + (sra-max-scalarization-size-Osize): Likewise. + * toplev.c (process_options): Set default values for new + parameters. + * tree-sra.c (analyze_all_variable_accesses): Use new parameters. + * targhooks.c (get_move_ratio): Remove static designator. + * target.h (get_move_ratio): Declare. + 2014-11-06 Marek Polacek * sanopt.c (sanopt_optimize_walker): Limit removal of the checks. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 209c8f6..2f89284 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10401,6 +10401,16 @@ parameters only when their cumulative size is less or equal to @option{ipa-sra-ptr-growth-factor} times the size of the original pointer parameter. +@item sra-max-scalarization-size-Ospeed +@item sra-max-scalarization-size-Osize +The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to +replace scalar parts of aggregates with uses of independent scalar +variables. These parameters control the maximum size, in storage units, +of aggregate which will be considered for replacement when compiling for +speed +(@option{sra-max-scalarization-size-Ospeed}) or size +(@option{sra-max-scalarization-size-Osize}) respectively. + @item tm-max-aggregate-size When making copies of thread-local variables in a transaction, this parameter specifies the size in bytes after which variables are diff --git a/gcc/params.def b/gcc/params.def index 73f5643..d2d2add 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -950,6 +950,18 @@ DEFPARAM (PARAM_TM_MAX_AGGREGATE_SIZE, "pairs", 9, 0, 0) +DEFPARAM (PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED, + "sra-max-scalarization-size-Ospeed", + "Maximum size, in storage units, of an aggregate which should be " + "considered for scalarization when compiling for speed", + 0, 0, 0) + +DEFPARAM (PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE, + "sra-max-scalarization-size-Osize", + "Maximum size, in storage units, of an aggregate which should be " + "considered for scalarization when compiling for size", + 0, 0, 0) + DEFPARAM (PARAM_IPA_CP_VALUE_LIST_SIZE, "ipa-cp-value-list-size", "Maximum size of a list of values associated with each parameter for " diff --git a/gcc/target.h b/gcc/target.h index 40d7841..65250ed 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -102,6 +102,10 @@ extern int elf_record_gcc_switches (print_switch_type type, const char *); we disable such optimizations on such targets, using this function. */ extern bool target_default_pointer_address_modes_p (void); +/* For hooks which use the MOVE_RATIO macro, this gives the legacy default + behaviour. */ +extern unsigned int get_move_ratio (bool); + struct stdarg_info; struct spec_info_def; struct hard_reg_set_container; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 3160016..7b1b5dc 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1409,7 +1409,7 @@ default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, /* For hooks which use the MOVE_RATIO macro, this gives the legacy default behaviour. SPEED_P is true if we are compiling for speed. */ -static unsigned int +unsigned int get_move_ratio (bool speed_p ATTRIBUTE_UNUSED) { unsigned int move_ratio; diff --git a/gcc/toplev.c b/gcc/toplev.c index 9c75dd8..ef2a813 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1270,6 +1270,20 @@ process_options (void) so we can correctly initialize debug output. */ no_backend = lang_hooks.post_options (&main_input_filename); + /* Set default values for parameters relation to the Scalar Reduction + of Aggregates passes (SRA and IP-SRA). We must do this here, rather + than in opts.c:default_options_optimization as historically these + tuning heuristics have been based on MOVE_RATIO, which on some + targets requires other symbols from the backend. */ + maybe_set_param_value + (PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED, + get_move_ratio (true) * UNITS_PER_WORD, + global_options.x_param_values, global_options_set.x_param_values); + maybe_set_param_value + (PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE, + get_move_ratio (false) * UNITS_PER_WORD, + global_options.x_param_values, global_options_set.x_param_values); + /* Some machines may reject certain combinations of options. */ targetm.target_option.override (); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index b723ca5..1e629bc 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2511,10 +2511,12 @@ analyze_all_variable_accesses (void) int res = 0; bitmap tmp = BITMAP_ALLOC (NULL); bitmap_iterator bi; - unsigned i, max_total_scalarization_size; - - max_total_scalarization_size = UNITS_PER_WORD * BITS_PER_UNIT - * MOVE_RATIO (optimize_function_for_speed_p (cfun)); + unsigned i; + unsigned max_scalarization_size + = (optimize_function_for_size_p (cfun) + ? PARAM_VALUE (PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE) + : PARAM_VALUE (PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED)) + * BITS_PER_UNIT; EXECUTE_IF_SET_IN_BITMAP (candidate_bitmap, 0, i, bi) if (bitmap_bit_p (should_scalarize_away_bitmap, i) @@ -2526,7 +2528,7 @@ analyze_all_variable_accesses (void) && type_consists_of_records_p (TREE_TYPE (var))) { if (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var))) - <= max_total_scalarization_size) + <= max_scalarization_size) { completely_scalarize_var (var); if (dump_file && (dump_flags & TDF_DETAILS)) -- cgit v1.1