Previously, turning -funroll-loops on at -O2, which also turn on GIMPLE cunroll fully. While cunroll unrolls some complex loops.
This patch turn on -frtl-unroll-loops at -O2 only, and continue to use previous tuned rs6000 heurisitics for small loops. While this patch does not turn on GIMPLE cunroll any more. We may tune cunroll in near future at -O2. In this patch, it become simpler to check/set -fweb, -frename-register and -munroll-only-small-loops. Together with -frtl-unroll-loops, -fweb is useful, then turn -fweb on; and -frename-registers is no need to be checked, because it is affected by -frtl-unroll-loops. Bootstrap and regtest pass on powerpc64le, is this ok for trunk? And backport to GCC10 together with the patch "Seperate -funroll-loops for GIMPLE unroller and RTL unroller" Jiufu gcc/ChangeLog 2020-05-25 Jiufu Guo <guoji...@cn.ibm.com> PR target/95018 * common/config/rs6000/rs6000-common.c (rs6000_option_optimization_table) [OPT_LEVELS_2_PLUS_SPEED_ONLY]: Replace -funroll-loops with -frtl-unroll-loops. Remove -munroll-only-small-loops and add -fweb. [OPT_LEVELS_ALL]: Remove turn off -frename-registers. * config/rs6000/rs6000.c (rs6000_option_override_internal): -funroll-loops overrides -munroll-only-small-loops and -frtl-unroll-loops. --- gcc/common/config/rs6000/rs6000-common.c | 11 +++-------- gcc/config/rs6000/rs6000.c | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/gcc/common/config/rs6000/rs6000-common.c b/gcc/common/config/rs6000/rs6000-common.c index ee37b9dc90b..c7388edb867 100644 --- a/gcc/common/config/rs6000/rs6000-common.c +++ b/gcc/common/config/rs6000/rs6000-common.c @@ -34,14 +34,9 @@ static const struct default_options rs6000_option_optimization_table[] = { OPT_LEVELS_ALL, OPT_fsplit_wide_types_early, NULL, 1 }, /* Enable -fsched-pressure for first pass instruction scheduling. */ { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 }, - /* Enable -munroll-only-small-loops with -funroll-loops to unroll small - loops at -O2 and above by default. */ - { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_funroll_loops, NULL, 1 }, - { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_munroll_only_small_loops, NULL, 1 }, - - /* -frename-registers leads to non-optimal codegen and performance - on rs6000, turn it off by default. */ - { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 }, + /* Enable -frtl-unroll-loops and -fweb at -O2 and above by default. */ + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_frtl_unroll_loops, NULL, 1 }, + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fweb, NULL, 1 }, /* Double growth factor to counter reduced min jump length. */ { OPT_LEVELS_ALL, OPT__param_max_grow_copy_bb_insns_, NULL, 16 }, diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 8435bc15d72..96620651a59 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4557,17 +4557,16 @@ rs6000_option_override_internal (bool global_init_p) param_sched_pressure_algorithm, SCHED_PRESSURE_MODEL); - /* Explicit -funroll-loops turns -munroll-only-small-loops off, and - turns -frename-registers on. */ - if ((global_options_set.x_flag_unroll_loops && flag_unroll_loops) - || (global_options_set.x_flag_unroll_all_loops - && flag_unroll_all_loops)) - { - if (!global_options_set.x_unroll_only_small_loops) - unroll_only_small_loops = 0; - if (!global_options_set.x_flag_rename_registers) - flag_rename_registers = 1; - } + /* if -f[no-]unroll-loops is specified explicitly, turn [off/]on + -frtl-unroll-loops. */ + if (global_options_set.x_flag_unroll_loops + && !global_options_set.x_flag_rtl_unroll_loops) + flag_rtl_unroll_loops = flag_unroll_loops; + + /* If flag_unroll_loops is effect, not _only_ small loops, but + large loops are unrolled if possible. */ + if (!global_options_set.x_unroll_only_small_loops) + unroll_only_small_loops = flag_unroll_loops ? 0 : 1; /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0) can be optimized to -- 2.17.1