diff mbox

Add flag to control straight-line strength reduction

Message ID 1342538095.3470.59.camel@gnopaine
State New
Headers show

Commit Message

Bill Schmidt July 17, 2012, 3:14 p.m. UTC
I overlooked adding a pass-control flag for strength reduction, added
here.  I named it -ftree-slsr for consistency with other -ftree- flags,
but could change it to -fgimple-slsr if you prefer that for a pass named
gimple-ssa-...

Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
regressions.  Ok for trunk?

Thanks,
Bill


2012-07-17  Bill Schmidt  <wschmidt@linux.ibm.com>

	* opts.c (default_option): Make -ftree-slsr default at -O1 and above.
	* gimple-ssa-strength-reduction.c (gate_strength_reduction): Use
	flag_tree_slsr.
	* common.opt: Add -ftree-slsr with flag_tree_slsr.

Comments

Richard Biener July 18, 2012, 7:59 a.m. UTC | #1
On Tue, 17 Jul 2012, William J. Schmidt wrote:

> I overlooked adding a pass-control flag for strength reduction, added
> here.  I named it -ftree-slsr for consistency with other -ftree- flags,
> but could change it to -fgimple-slsr if you prefer that for a pass named
> gimple-ssa-...
> 
> Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
> regressions.  Ok for trunk?

The switch needs documentation in doc/invoke.texi.  Other than that
it's fine to stick with -ftree-..., even that exposes details to our
users that are not necessary (RTL passes didn't have -frtl-... either).
So in the end, why not re-use -fstrength-reduce that is already available
(but stubbed out)?

Comments from other folks?

Thanks,
Richard.

> Thanks,
> Bill
> 
> 
> 2012-07-17  Bill Schmidt  <wschmidt@linux.ibm.com>
> 
> 	* opts.c (default_option): Make -ftree-slsr default at -O1 and above.
> 	* gimple-ssa-strength-reduction.c (gate_strength_reduction): Use
> 	flag_tree_slsr.
> 	* common.opt: Add -ftree-slsr with flag_tree_slsr.
> 
> 
> Index: gcc/opts.c
> ===================================================================
> --- gcc/opts.c	(revision 189574)
> +++ gcc/opts.c	(working copy)
> @@ -452,6 +452,7 @@ static const struct default_options default_option
>      { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fcompare_elim, NULL, 1 },
> +    { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
>  
>      /* -O2 optimizations.  */
>      { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 },
> Index: gcc/gimple-ssa-strength-reduction.c
> ===================================================================
> --- gcc/gimple-ssa-strength-reduction.c	(revision 189574)
> +++ gcc/gimple-ssa-strength-reduction.c	(working copy)
> @@ -1501,7 +1501,7 @@ execute_strength_reduction (void)
>  static bool
>  gate_strength_reduction (void)
>  {
> -  return optimize > 0;
> +  return flag_tree_slsr;
>  }
>  
>  struct gimple_opt_pass pass_strength_reduction =
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt	(revision 189574)
> +++ gcc/common.opt	(working copy)
> @@ -2080,6 +2080,10 @@ ftree-sink
>  Common Report Var(flag_tree_sink) Optimization
>  Enable SSA code sinking on trees
>  
> +ftree-slsr
> +Common Report Var(flag_tree_slsr) Optimization
> +Perform straight-line strength reduction
> +
>  ftree-sra
>  Common Report Var(flag_tree_sra) Optimization
>  Perform scalar replacement of aggregates
> 
> 
>
Steven Bosscher July 18, 2012, 8:11 a.m. UTC | #2
On Wed, Jul 18, 2012 at 9:59 AM, Richard Guenther <rguenther@suse.de> wrote:
> On Tue, 17 Jul 2012, William J. Schmidt wrote:
>
>> I overlooked adding a pass-control flag for strength reduction, added
>> here.  I named it -ftree-slsr for consistency with other -ftree- flags,
>> but could change it to -fgimple-slsr if you prefer that for a pass named
>> gimple-ssa-...
>>
>> Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
>> regressions.  Ok for trunk?
>
> The switch needs documentation in doc/invoke.texi.  Other than that
> it's fine to stick with -ftree-..., even that exposes details to our
> users that are not necessary (RTL passes didn't have -frtl-... either).
> So in the end, why not re-use -fstrength-reduce that is already available
> (but stubbed out)?

In the past, -fstrength-reduce applied to loop strength reduction in
loop.c. I don't think it should be re-used for a completely different
code transformation.

Ciao!
Steven
Richard Biener July 18, 2012, 9:01 a.m. UTC | #3
On Wed, 18 Jul 2012, Steven Bosscher wrote:

> On Wed, Jul 18, 2012 at 9:59 AM, Richard Guenther <rguenther@suse.de> wrote:
> > On Tue, 17 Jul 2012, William J. Schmidt wrote:
> >
> >> I overlooked adding a pass-control flag for strength reduction, added
> >> here.  I named it -ftree-slsr for consistency with other -ftree- flags,
> >> but could change it to -fgimple-slsr if you prefer that for a pass named
> >> gimple-ssa-...
> >>
> >> Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
> >> regressions.  Ok for trunk?
> >
> > The switch needs documentation in doc/invoke.texi.  Other than that
> > it's fine to stick with -ftree-..., even that exposes details to our
> > users that are not necessary (RTL passes didn't have -frtl-... either).
> > So in the end, why not re-use -fstrength-reduce that is already available
> > (but stubbed out)?
> 
> In the past, -fstrength-reduce applied to loop strength reduction in
> loop.c. I don't think it should be re-used for a completely different
> code transformation.

Ok.  I suppose -ftree-slsr is ok then.

Thanks,
Richard.
Eric Botcazou July 18, 2012, 9:02 a.m. UTC | #4
> In the past, -fstrength-reduce applied to loop strength reduction in
> loop.c. I don't think it should be re-used for a completely different
> code transformation.

Seconded.
Bill Schmidt July 18, 2012, 1:24 p.m. UTC | #5
On Wed, 2012-07-18 at 11:01 +0200, Richard Guenther wrote:
> On Wed, 18 Jul 2012, Steven Bosscher wrote:
> 
> > On Wed, Jul 18, 2012 at 9:59 AM, Richard Guenther <rguenther@suse.de> wrote:
> > > On Tue, 17 Jul 2012, William J. Schmidt wrote:
> > >
> > >> I overlooked adding a pass-control flag for strength reduction, added
> > >> here.  I named it -ftree-slsr for consistency with other -ftree- flags,
> > >> but could change it to -fgimple-slsr if you prefer that for a pass named
> > >> gimple-ssa-...
> > >>
> > >> Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
> > >> regressions.  Ok for trunk?
> > >
> > > The switch needs documentation in doc/invoke.texi.  Other than that
> > > it's fine to stick with -ftree-..., even that exposes details to our
> > > users that are not necessary (RTL passes didn't have -frtl-... either).
> > > So in the end, why not re-use -fstrength-reduce that is already available
> > > (but stubbed out)?
> > 
> > In the past, -fstrength-reduce applied to loop strength reduction in
> > loop.c. I don't think it should be re-used for a completely different
> > code transformation.
> 
> Ok.  I suppose -ftree-slsr is ok then.

It turns out I was looking at a very old copy of the manual, and the
-ftree... stuff is not as prevalent now as it once was.  I'll just go
with -fslsr to be consistent with -fgcse, -fipa-sra, etc.

Thanks for the pointer to doc/invoke.texi -- it appears I also failed to
document -fhoist-adjacent-loads, so I will go ahead and do that as well.

Thanks!
Bill

> 
> Thanks,
> Richard.
>
Bill Schmidt July 18, 2012, 1:28 p.m. UTC | #6
On Wed, 2012-07-18 at 08:24 -0500, William J. Schmidt wrote:
> On Wed, 2012-07-18 at 11:01 +0200, Richard Guenther wrote:
> > On Wed, 18 Jul 2012, Steven Bosscher wrote:
> > 
> > > On Wed, Jul 18, 2012 at 9:59 AM, Richard Guenther <rguenther@suse.de> wrote:
> > > > On Tue, 17 Jul 2012, William J. Schmidt wrote:
> > > >
> > > >> I overlooked adding a pass-control flag for strength reduction, added
> > > >> here.  I named it -ftree-slsr for consistency with other -ftree- flags,
> > > >> but could change it to -fgimple-slsr if you prefer that for a pass named
> > > >> gimple-ssa-...
> > > >>
> > > >> Bootstrapped and tested on powerpc-unknown-linux-gnu with no new
> > > >> regressions.  Ok for trunk?
> > > >
> > > > The switch needs documentation in doc/invoke.texi.  Other than that
> > > > it's fine to stick with -ftree-..., even that exposes details to our
> > > > users that are not necessary (RTL passes didn't have -frtl-... either).
> > > > So in the end, why not re-use -fstrength-reduce that is already available
> > > > (but stubbed out)?
> > > 
> > > In the past, -fstrength-reduce applied to loop strength reduction in
> > > loop.c. I don't think it should be re-used for a completely different
> > > code transformation.
> > 
> > Ok.  I suppose -ftree-slsr is ok then.
> 
> It turns out I was looking at a very old copy of the manual, and the
> -ftree... stuff is not as prevalent now as it once was.  I'll just go
> with -fslsr to be consistent with -fgcse, -fipa-sra, etc.

Well, posted too fast.  Paging down I see that isn't true, sorry.  I'll
use the tree- for consistency even though it is useless information.

Thanks,
Bill

> 
> Thanks for the pointer to doc/invoke.texi -- it appears I also failed to
> document -fhoist-adjacent-loads, so I will go ahead and do that as well.
> 
> Thanks!
> Bill
> 
> > 
> > Thanks,
> > Richard.
> > 
>
Steven Bosscher July 18, 2012, 2:14 p.m. UTC | #7
On Wed, Jul 18, 2012 at 3:24 PM, William J. Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> It turns out I was looking at a very old copy of the manual, and the
> -ftree... stuff is not as prevalent now as it once was.  I'll just go
> with -fslsr to be consistent with -fgcse, -fipa-sra, etc.

Sadly, it is more prevalent than it ever was!
It's IMHO very unfortunate that such an internal detail is exposed to
the user...

Ciao!
Steven
Richard Biener July 18, 2012, 2:36 p.m. UTC | #8
On Wed, 18 Jul 2012, Steven Bosscher wrote:

> On Wed, Jul 18, 2012 at 3:24 PM, William J. Schmidt
> <wschmidt@linux.vnet.ibm.com> wrote:
> > It turns out I was looking at a very old copy of the manual, and the
> > -ftree... stuff is not as prevalent now as it once was.  I'll just go
> > with -fslsr to be consistent with -fgcse, -fipa-sra, etc.
> 
> Sadly, it is more prevalent than it ever was!
> It's IMHO very unfortunate that such an internal detail is exposed to
> the user...

Indeed...  not sure if we want a set of aliases without the tree-
or rtl- part.

Richard.
diff mbox

Patch

Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 189574)
+++ gcc/opts.c	(working copy)
@@ -452,6 +452,7 @@  static const struct default_options default_option
     { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_fcompare_elim, NULL, 1 },
+    { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
 
     /* -O2 optimizations.  */
     { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 },
Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c	(revision 189574)
+++ gcc/gimple-ssa-strength-reduction.c	(working copy)
@@ -1501,7 +1501,7 @@  execute_strength_reduction (void)
 static bool
 gate_strength_reduction (void)
 {
-  return optimize > 0;
+  return flag_tree_slsr;
 }
 
 struct gimple_opt_pass pass_strength_reduction =
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 189574)
+++ gcc/common.opt	(working copy)
@@ -2080,6 +2080,10 @@  ftree-sink
 Common Report Var(flag_tree_sink) Optimization
 Enable SSA code sinking on trees
 
+ftree-slsr
+Common Report Var(flag_tree_slsr) Optimization
+Perform straight-line strength reduction
+
 ftree-sra
 Common Report Var(flag_tree_sra) Optimization
 Perform scalar replacement of aggregates