/* The STC algorithm produces the smallest code at -Os, for x86. */
{ OPT_LEVELS_2_PLUS, OPT_freorder_blocks_algorithm_, NULL,
REORDER_BLOCKS_ALGORITHM_STC },
+
+ /* Turn on -funroll-loops with -munroll-only-small-loops to enable small
+ loop unrolling at -O2. */
+ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_funroll_loops, NULL, 1 },
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_munroll_only_small_loops, NULL, 1 },
+ /* Turns off -frename-registers and -fweb which are enabled by
+ funroll-loops. */
+ { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 },
+ { OPT_LEVELS_ALL, OPT_fweb, NULL, 0 },
/* Turn off -fschedule-insns by default. It tends to make the
problem with not enough registers even worse. */
{ OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 },
void
ix86_override_options_after_change (void)
{
+ /* Default align_* from the processor table. */
ix86_default_align (&global_options);
+
ix86_recompute_optlev_based_flags (&global_options, &global_options_set);
+
+ /* Disable unrolling small loops when there's explicit
+ -f{,no}unroll-loop. */
+ if ((OPTION_SET_P (flag_unroll_loops))
+ || (OPTION_SET_P (flag_unroll_all_loops)
+ && flag_unroll_all_loops))
+ {
+ if (!OPTION_SET_P (ix86_unroll_only_small_loops))
+ ix86_unroll_only_small_loops = 0;
+ /* Re-enable -frename-registers and -fweb if funroll-loops
+ enabled. */
+ if (!OPTION_SET_P (flag_web))
+ flag_web = flag_unroll_loops;
+ if (!OPTION_SET_P (flag_rename_registers))
+ flag_rename_registers = flag_unroll_loops;
+ /* -fcunroll-grow-size default follws -f[no]-unroll-loops. */
+ if (!OPTION_SET_P (flag_cunroll_grow_size))
+ flag_cunroll_grow_size = flag_unroll_loops
+ || flag_peel_loops
+ || optimize >= 3;
+ }
+ else
+ {
+ if (!OPTION_SET_P (flag_cunroll_grow_size))
+ flag_cunroll_grow_size = flag_peel_loops || optimize >= 3;
+ }
+
}
/* Clear stack slot assignments remembered from previous functions.
set_ix86_tune_features (opts, ix86_tune, opts->x_ix86_dump_tunes);
- ix86_recompute_optlev_based_flags (opts, opts_set);
+ ix86_override_options_after_change ();
ix86_tune_cost = processor_cost_table[ix86_tune];
/* TODO: ix86_cost should be chosen at instruction or function granuality
|| TARGET_64BIT_P (opts->x_ix86_isa_flags))
opts->x_ix86_regparm = REGPARM_MAX;
- /* Default align_* from the processor table. */
- ix86_default_align (opts);
-
/* Provide default for -mbranch-cost= value. */
SET_OPTION_IF_UNSET (opts, opts_set, ix86_branch_cost,
ix86_tune_cost->branch_cost);
/* Unroll small size loop when unroll factor is not explicitly
specified. */
- if (!(flag_unroll_loops
- || flag_unroll_all_loops
- || loop->unroll))
+ if (ix86_unroll_only_small_loops && !loop->unroll)
{
- nunroll = 1;
-
- /* Any explicit -f{no-}unroll-{all-}loops turns off
- -munroll-only-small-loops. */
- if (ix86_unroll_only_small_loops
- && !OPTION_SET_P (flag_unroll_loops)
- && loop->ninsns <= ix86_cost->small_unroll_ninsns)
- nunroll = ix86_cost->small_unroll_factor;
-
- return nunroll;
+ if (loop->ninsns <= ix86_cost->small_unroll_ninsns)
+ return MIN (nunroll, ix86_cost->small_unroll_factor);
+ else
+ return 1;
}
if (!TARGET_ADJUST_UNROLL)
{}
/* opt_pass methods: */
- bool gate (function *fun) final override
+ bool gate (function *) final override
{
- return (flag_unroll_loops || flag_unroll_all_loops || cfun->has_unroll
- || (targetm.loop_unroll_adjust
- && optimize >= 2
- && optimize_function_for_speed_p (fun)));
+ return (flag_unroll_loops || flag_unroll_all_loops
+ || cfun->has_unroll);
}
unsigned int execute (function *) final override;
if (dump_file)
df_dump (dump_file);
- if (flag_unroll_loops
- || targetm.loop_unroll_adjust)
+ if (flag_unroll_loops)
flags |= UAP_UNROLL;
if (flag_unroll_all_loops)
flags |= UAP_UNROLL_ALL;
/* { dg-do run } */
/* { dg-options "-fno-tree-scev-cprop -fno-tree-vectorize -g" } */
-/* { dg-additional-options "-mno-unroll-only-small-loops" { target ia32 } } */
-
#include "../nop.h"
/* { dg-do compile } */
-/* { dg-options "-O2 -mno-unroll-only-small-loops" } */
+/* { dg-options "-O2 -fno-unroll-loops" } */
int *a;
long len;
/* PR target/93002 */
/* { dg-do compile } */
-/* { dg-options "-O2 -mno-unroll-only-small-loops" } */
+/* { dg-options "-O2 -fno-unroll-loops" } */
/* { dg-final { scan-assembler-not "cmp\[^\n\r]*-1" } } */
volatile int sink;