On Thu, Jul 27, 2017 at 03:21:01PM +0100, James Greenhalgh wrote:
> On Thu, Jul 27, 2017 at 02:26:03PM +0200, Richard Biener wrote:
> > On Thu, Jul 27, 2017 at 2:08 PM, Jakub Jelinek <[email protected]> wrote:
> > > On Thu, Jul 27, 2017 at 01:54:21PM +0200, Richard Biener wrote:
> > >> --- gcc/common.opt (revision 250619)
> > >> +++ gcc/common.opt (working copy)
> > >> ftree-vectorize
> > >> -Common Report Var(flag_tree_vectorize) Optimization
> > >> +Common Report Optimization
> > >> Enable vectorization on trees.
> > >>
> > >> ftree-vectorizer-verbose=
> > >>
> > >> which shows a few other uses of flag_tree_vectorize:
> > >>
> > >> int
> > >> omp_max_vf (void)
> > >> {
> > >> if (!optimize
> > >> || optimize_debug
> > >> || !flag_tree_loop_optimize
> > >> || (!flag_tree_loop_vectorize
> > >> && (global_options_set.x_flag_tree_loop_vectorize
> > >> || global_options_set.x_flag_tree_vectorize)))
> > >> return 1;
> > >>
> > >> not sure what that was supposed to test. Jakub? Similar
> > >> use in expand_omp_simd.
> > >
> > > The intent is/was to check if the vectorizer pass will be invoked,
> > > otherwise it makes no sense to generate the arrays.
> > > So, for -O0/-Og or -fno-tree-loop-optimize, we know that the pass
> > > isn't even in the pipeline.
> > > And otherwise the intent was that we try to optimize, unless
> > > user asked explicitly -fno-tree-loop-vectorize or -fno-tree-vectorize
> > > not to optimize. Because the vect pass is enabled if:
> > > flag_tree_loop_vectorize || fun->has_force_vectorize_loops
> > > but returning non-zero from omp_max_vf and the other omp spot means
> > > there will be cfun->has_force_vectorize_loops.
> >
> > I see. So it would be good to try if adding EnabledBy(ftree-vectorize) to
> > ftree-loop-vectorize/ftree-slp-vectorize would add those to
> > global_options_set
> > iff -ftree-vectorize is enabled (the opts.c hunk setting the flags is then
> > redundant as well I guess).
>
> This looks like it works.
>
> I'll prepare the patch and put it through a full bootstrap cycle.
That patch looks like this, and was bootstrapped and tested on
aarch64-none-linux-gnu with no issues. I've also checked that -ftree-vectorize
causes -ftree-loop-vectorize and -ftree-slp-vectorize to appear in the verbose
asm dump as enabled, and that -fprofile-use still correctly turns on
both of the options. Finally I've checked that -fprofile-use
-fno-tree-vectorize correctly results in neither of the options being
enabled.
OK?
Thanks,
James
---
2017-07-28 James Greenhalgh <[email protected]>
* common.opt (ftree-vectorize): No longer set flag_tree_vectorize.
(ftree-loop-vectorize): Set as EnabledBy ftree-vectorize.
(ftree-slp-vectorize): Likewise.
* omp-expand (expand_omp_simd): Remove flag_tree_vectorize, as it
can no longer be set independent of flag_tree_loop_vectorize.
* omp-general.c (emp_max_vf): Likewise.
* opts.c (enable_fdo_optimizations): Remove references to
flag_tree_vectorize, these are now implicit.
(common_handle_option): Remove handling for OPT_ftree_vectorize,
and leave it for the options machinery.
diff --git a/gcc/common.opt b/gcc/common.opt
index 78cfa56..1cb1c83 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2691,8 +2691,9 @@ fvar-tracking-uninit
Common Report Var(flag_var_tracking_uninit) PerFunction
Perform variable tracking and also tag variables that are uninitialized.
+; Alias to enable both -ftree-loop-vectorize and -ftree-slp-vectorize.
ftree-vectorize
-Common Report Var(flag_tree_vectorize) Optimization
+Common Report Optimization
Enable vectorization on trees.
ftree-vectorizer-verbose=
@@ -2700,11 +2701,11 @@ Common Joined RejectNegative Ignore
Does nothing. Preserved for backward compatibility.
ftree-loop-vectorize
-Common Report Var(flag_tree_loop_vectorize) Optimization
+Common Report Var(flag_tree_loop_vectorize) Optimization EnabledBy(ftree-vectorize)
Enable loop vectorization on trees.
ftree-slp-vectorize
-Common Report Var(flag_tree_slp_vectorize) Optimization
+Common Report Var(flag_tree_slp_vectorize) Optimization EnabledBy(ftree-vectorize)
Enable basic block vectorization (SLP) on trees.
fvect-cost-model=
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index d6755cd..970e04f 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -4851,8 +4851,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
/* If not -fno-tree-loop-vectorize, hint that we want to vectorize
the loop. */
if ((flag_tree_loop_vectorize
- || (!global_options_set.x_flag_tree_loop_vectorize
- && !global_options_set.x_flag_tree_vectorize))
+ || !global_options_set.x_flag_tree_loop_vectorize)
&& flag_tree_loop_optimize
&& loop->safelen > 1)
{
diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index 9a5ed88..ed94668 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -429,8 +429,7 @@ omp_max_vf (void)
|| optimize_debug
|| !flag_tree_loop_optimize
|| (!flag_tree_loop_vectorize
- && (global_options_set.x_flag_tree_loop_vectorize
- || global_options_set.x_flag_tree_vectorize)))
+ && global_options_set.x_flag_tree_loop_vectorize))
return 1;
int vf = 1;
diff --git a/gcc/opts.c b/gcc/opts.c
index 2f9a638..989cc6b 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1477,11 +1477,9 @@ enable_fdo_optimizations (struct gcc_options *opts,
opts->x_flag_unswitch_loops = value;
if (!opts_set->x_flag_gcse_after_reload)
opts->x_flag_gcse_after_reload = value;
- if (!opts_set->x_flag_tree_loop_vectorize
- && !opts_set->x_flag_tree_vectorize)
+ if (!opts_set->x_flag_tree_loop_vectorize)
opts->x_flag_tree_loop_vectorize = value;
- if (!opts_set->x_flag_tree_slp_vectorize
- && !opts_set->x_flag_tree_vectorize)
+ if (!opts_set->x_flag_tree_slp_vectorize)
opts->x_flag_tree_slp_vectorize = value;
if (!opts_set->x_flag_vect_cost_model)
opts->x_flag_vect_cost_model = VECT_COST_MODEL_DYNAMIC;
@@ -2236,10 +2234,8 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_ftree_vectorize:
- if (!opts_set->x_flag_tree_loop_vectorize)
- opts->x_flag_tree_loop_vectorize = value;
- if (!opts_set->x_flag_tree_slp_vectorize)
- opts->x_flag_tree_slp_vectorize = value;
+ /* Automatically sets -ftree-loop-vectorize and
+ -ftree-slp-vectorize. Nothing more to do here. */
break;
case OPT_fshow_column:
dc->show_column = value;