aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-08-12 17:00:41 +0200
committerJakub Jelinek <jakub@redhat.com>2020-08-12 17:00:41 +0200
commitfe9458c280dbd6e8b892db4ca3b64185049c376b (patch)
tree9156a7d995e9daa69fbe8f8b98c8f918db9df51e /gcc/opts.c
parenta12026e9dd19caee8ce2f53e703564480e9709d4 (diff)
downloadgcc-fe9458c280dbd6e8b892db4ca3b64185049c376b.zip
gcc-fe9458c280dbd6e8b892db4ca3b64185049c376b.tar.gz
gcc-fe9458c280dbd6e8b892db4ca3b64185049c376b.tar.bz2
Fix up flag_cunroll_grow_size handling in presence of optimize attr [PR96535]
As the testcase in the PR shows (not included in the patch, as it seems quite fragile to observe unrolling in the IL), the introduction of flag_cunroll_grow_size broke optimize attribute related to loop unrolling. The problem is that the new option flag is set (if not set explicitly) only in process_options and in rs6000_option_override_internal (and there only if global_init_p). So, this means that while it is Optimization option, it will only be set based on the command line -funroll-loops/-O3/-fpeel-loops or -funroll-all-loops, which means that if command line does include any of those, it is enabled even for functions that will through optimize attribute have all of those disabled, and if command line does not include those, it will not be enabled for functions that will through optimize attribute have any of those enabled. process_options is called just once, so IMHO it should be handling only non-Optimization option adjustments (various other options suffer from that too, but as this is a regression from 10.1 on the 10 branch, changing those is not appropriate). Similarly, rs6000_option_override_internal is called only once (with global_init_p) and then for target attribute handling, but not for optimize attribute handling. This patch moves the unrolling related handling from process_options into finish_options which is invoked whenever the options are being finalized, and the rs6000 specific parts into the override_options_after_change hook which is called for optimize attribute handling (and unfortunately also th cfun changes, but what the hook does is cheap) and I've added a call to that from rs6000_override_options_internal, so it is also called on cmdline processing and for target attribute. Furthermore, it stops using AUTODETECT_VALUE, which can work only once, and instead uses the global_options_set.x_... flags. 2020-08-12 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/96535 * toplev.c (process_options): Move flag_unroll_loops and flag_cunroll_grow_size handling from here to ... * opts.c (finish_options): ... here. For flag_cunroll_grow_size, don't check for AUTODETECT_VALUE, but instead check opts_set->x_flag_cunroll_grow_size. * common.opt (funroll-completely-grow-size): Default to 0. * config/rs6000/rs6000.c (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Redefine. (rs6000_override_options_after_change): New function. (rs6000_option_override_internal): Call it. Move there the flag_cunroll_grow_size, unroll_only_small_loops and flag_rename_registers handling.
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 63c995d..c5c6058 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1142,11 +1142,21 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
/* Control IPA optimizations based on different -flive-patching level. */
if (opts->x_flag_live_patching)
- {
- control_options_for_live_patching (opts, opts_set,
- opts->x_flag_live_patching,
- loc);
- }
+ control_options_for_live_patching (opts, opts_set,
+ opts->x_flag_live_patching,
+ loc);
+
+ /* Unrolling all loops implies that standard loop unrolling must also
+ be done. */
+ if (opts->x_flag_unroll_all_loops)
+ opts->x_flag_unroll_loops = 1;
+
+ /* Allow cunroll to grow size accordingly. */
+ if (!opts_set->x_flag_cunroll_grow_size)
+ opts->x_flag_cunroll_grow_size
+ = (opts->x_flag_unroll_loops
+ || opts->x_flag_peel_loops
+ || opts->x_optimize >= 3);
}
#define LEFT_COLUMN 27