Two other params do similar scaling so fix them similarly.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2019-10-14 Richard Biener <rguent...@suse.de> PR middle-end/92046 * dse.c (scan_insn): Use param max_active_local_stores. (dse_step1): Get PARAM_MAX_DSE_ACTIVE_LOCAL_STORES and adjust based on optimization level. * loop-invariant.c (move_loop_invariants): Adjust LOOP_INVARIANT_MAX_BBS_IN_LOOP based on optimization level. * opts.c (default_options_optimization): Do not adjust PARAM_MAX_DSE_ACTIVE_LOCAL_STORES and LOOP_INVARIANT_MAX_BBS_IN_LOOP here. Index: gcc/dse.c =================================================================== --- gcc/dse.c (revision 276961) +++ gcc/dse.c (working copy) @@ -2401,7 +2401,7 @@ copy_fixed_regs (const_bitmap in) non-register target. */ static void -scan_insn (bb_info_t bb_info, rtx_insn *insn) +scan_insn (bb_info_t bb_info, rtx_insn *insn, int max_active_local_stores) { rtx body; insn_info_type *insn_info = insn_info_type_pool.allocate (); @@ -2523,8 +2523,7 @@ scan_insn (bb_info_t bb_info, rtx_insn * fprintf (dump_file, "handling memset as BLKmode store\n"); if (mems_found == 1) { - if (active_local_stores_len++ - >= PARAM_VALUE (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES)) + if (active_local_stores_len++ >= max_active_local_stores) { active_local_stores_len = 1; active_local_stores = NULL; @@ -2584,8 +2583,7 @@ scan_insn (bb_info_t bb_info, rtx_insn * it as cannot delete. This simplifies the processing later. */ if (mems_found == 1) { - if (active_local_stores_len++ - >= PARAM_VALUE (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES)) + if (active_local_stores_len++ >= max_active_local_stores) { active_local_stores_len = 1; active_local_stores = NULL; @@ -2657,6 +2655,12 @@ dse_step1 (void) bitmap_set_bit (all_blocks, ENTRY_BLOCK); bitmap_set_bit (all_blocks, EXIT_BLOCK); + /* For -O1 reduce the maximum number of active local stores for RTL DSE + since this can consume huge amounts of memory (PR89115). */ + int max_active_local_stores = PARAM_VALUE (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES); + if (optimize < 2) + max_active_local_stores /= 10; + FOR_ALL_BB_FN (bb, cfun) { insn_info_t ptr; @@ -2684,7 +2688,7 @@ dse_step1 (void) FOR_BB_INSNS (bb, insn) { if (INSN_P (insn)) - scan_insn (bb_info, insn); + scan_insn (bb_info, insn, max_active_local_stores); cselib_process_insn (insn); if (INSN_P (insn)) df_simulate_one_insn_forwards (bb, insn, regs_live); Index: gcc/loop-invariant.c =================================================================== --- gcc/loop-invariant.c (revision 276961) +++ gcc/loop-invariant.c (working copy) @@ -2276,9 +2276,13 @@ move_loop_invariants (void) FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) { curr_loop = loop; - /* move_single_loop_invariants for very large loops - is time consuming and might need a lot of memory. */ - if (loop->num_nodes <= (unsigned) LOOP_INVARIANT_MAX_BBS_IN_LOOP) + /* move_single_loop_invariants for very large loops is time consuming + and might need a lot of memory. For -O1 only do loop invariant + motion for very small loops. */ + unsigned max_bbs = LOOP_INVARIANT_MAX_BBS_IN_LOOP; + if (optimize < 2) + max_bbs /= 10; + if (loop->num_nodes <= max_bbs) move_single_loop_invariants (loop); } Index: gcc/opts.c =================================================================== --- gcc/opts.c (revision 276961) +++ gcc/opts.c (working copy) @@ -671,21 +671,6 @@ default_options_optimization (struct gcc opt2 ? 100 : default_param_value (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE), opts->x_param_values, opts_set->x_param_values); - /* For -O1 only do loop invariant motion for very small loops. */ - maybe_set_param_value - (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP, - opt2 ? default_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) - : default_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) / 10, - opts->x_param_values, opts_set->x_param_values); - - /* For -O1 reduce the maximum number of active local stores for RTL DSE - since this can consume huge amounts of memory (PR89115). */ - maybe_set_param_value - (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES, - opt2 ? default_param_value (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES) - : default_param_value (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES) / 10, - opts->x_param_values, opts_set->x_param_values); - /* At -Ofast, allow store motion to introduce potential race conditions. */ maybe_set_param_value (PARAM_ALLOW_STORE_DATA_RACES,