Patchwork RFA; Add option to control combine-stack-adjustments pass

login
register
mail settings
Submitter Nick Clifton
Date Oct. 1, 2010, 10:41 a.m.
Message ID <m3iq1mmbzc.fsf@redhat.com>
Download mbox | patch
Permalink /patch/66334/
State New
Headers show

Comments

Nick Clifton - Oct. 1, 2010, 10:41 a.m.
Hi Guys,

  I recently ran into a problem with GCC's combine stack adjustment
  pass.  (It is breaking the relationship between CC0-setter and
  CC0-user).  I have not tracked down the exact cause of this problem
  yet, but I did find it odd that there was no way to control the use of
  the optimization from the command line.  So I have created the patch
  below.

  This patch adds a new command line option:

    -fcombine-stack-adjustments

  which is enabled by default at -O1 and greater and which controls the
  operation of the combine stack adjustments pass.

  Tested without regressions on an i686-pc-linux-gnu target.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2010-10-01  Nick Clifton  <nickc@redhat.com>

	* common.opt: Add -fcombine-stack-adjustments.
	* opts.c (decode_options): Enable -fcombine-stack-adjustments at
	-O1.
        * combine-stack-adj.c (gate_handle_stack_adjustments): Check
	* flag_combine_stack_adjustments.
	* doc.invoke.texi: Document the new option.
Richard Guenther - Oct. 1, 2010, 10:46 a.m.
On Fri, Oct 1, 2010 at 12:41 PM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
>  I recently ran into a problem with GCC's combine stack adjustment
>  pass.  (It is breaking the relationship between CC0-setter and
>  CC0-user).  I have not tracked down the exact cause of this problem
>  yet, but I did find it odd that there was no way to control the use of
>  the optimization from the command line.  So I have created the patch
>  below.
>
>  This patch adds a new command line option:
>
>    -fcombine-stack-adjustments
>
>  which is enabled by default at -O1 and greater and which controls the
>  operation of the combine stack adjustments pass.
>
>  Tested without regressions on an i686-pc-linux-gnu target.
>
>  OK to apply ?
>
> Cheers
>  Nick
>
> gcc/ChangeLog
> 2010-10-01  Nick Clifton  <nickc@redhat.com>
>
>        * common.opt: Add -fcombine-stack-adjustments.
>        * opts.c (decode_options): Enable -fcombine-stack-adjustments at
>        -O1.
>        * combine-stack-adj.c (gate_handle_stack_adjustments): Check
>        * flag_combine_stack_adjustments.
>        * doc.invoke.texi: Document the new option.

doc/invoke.texi

Ok with that change.

Thanks,
Richard.

> Index: gcc/doc/invoke.texi
> ===================================================================
> --- gcc/doc/invoke.texi (revision 164830)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -334,7 +334,8 @@
>  -falign-labels[=@var{n}] -falign-loops[=@var{n}] -fassociative-math @gol
>  -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize @gol
>  -fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves @gol
> --fcheck-data-deps -fconserve-stack -fcprop-registers -fcrossjumping @gol
> +-fcheck-data-deps -fcombine-stack-adjustments -fconserve-stack @gol
> +-fcprop-registers -fcrossjumping @gol
>  -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
>  -fcx-limited-range @gol
>  -fdata-sections -fdce -fdce @gol
> @@ -6618,6 +6619,13 @@
>
>  Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
>
> +@item -fcombine-stack-adjustments
> +@opindex fcombine-stack-adjustments
> +Tracks stack adjustments (pushes and pops) and stack memory references
> +and then tries to find ways to combine them.
> +
> +Enabled by default at @option{-O1} and higher.
> +
>  @item -fconserve-stack
>  @opindex fconserve-stack
>  Attempt to minimize stack usage.  The compiler will attempt to use less
> Index: gcc/opts.c
> ===================================================================
> --- gcc/opts.c  (revision 164830)
> +++ gcc/opts.c  (working copy)
> @@ -801,6 +801,7 @@
>   flag_tree_copy_prop = opt1;
>   flag_tree_sink = opt1;
>   flag_tree_ch = opt1;
> +  flag_combine_stack_adjustments = opt1;
>
>   /* -O2 optimizations.  */
>   opt2 = (optimize >= 2);
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt      (revision 164830)
> +++ gcc/common.opt      (working copy)
> @@ -640,6 +640,10 @@
>  Common Report Var(flag_check_data_deps)
>  Compare the results of several data dependence analyzers.
>
> +fcombine-stack-adjustments
> +Common Report Var(flag_combine_stack_adjustments) Optimization
> +Looks for opportunities to reduce stack adjustments and stack references.
> +
>  fcommon
>  Common Report Var(flag_no_common,0) Optimization
>  Do not put uninitialized globals in the common section
> Index: gcc/combine-stack-adj.c
> ===================================================================
> --- gcc/combine-stack-adj.c     (revision 164830)
> +++ gcc/combine-stack-adj.c     (working copy)
> @@ -546,7 +546,7 @@
>  static bool
>  gate_handle_stack_adjustments (void)
>  {
> -  return (optimize > 0);
> +  return flag_combine_stack_adjustments;
>  }
>
>  static unsigned int
>
Jakub Jelinek - Oct. 1, 2010, 10:55 a.m.
On Fri, Oct 01, 2010 at 12:46:24PM +0200, Richard Guenther wrote:
> On Fri, Oct 1, 2010 at 12:41 PM, Nick Clifton <nickc@redhat.com> wrote:
> > gcc/ChangeLog
> > 2010-10-01  Nick Clifton  <nickc@redhat.com>
> >
> >        * common.opt: Add -fcombine-stack-adjustments.
> >        * opts.c (decode_options): Enable -fcombine-stack-adjustments at
> >        -O1.
> >        * combine-stack-adj.c (gate_handle_stack_adjustments): Check
> >        * flag_combine_stack_adjustments.

And no "* " on the above line.

> >        * doc.invoke.texi: Document the new option.
> 
> doc/invoke.texi
> 
> Ok with that change.

	Jakub
Gerald Pfeifer - Oct. 17, 2010, 4:38 p.m.
Hi Nick,

On Fri, 1 Oct 2010, Nick Clifton wrote:
>   This patch adds a new command line option:
> 
>     -fcombine-stack-adjustments
> 
>   which is enabled by default at -O1 and greater and which controls the
>   operation of the combine stack adjustments pass.

would you mind also describing this in 
http://gcc.gnu.org/gcc-4.6/changes.html ?

Thanks,
Gerald

Patch

Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 164830)
+++ gcc/doc/invoke.texi	(working copy)
@@ -334,7 +334,8 @@ 
 -falign-labels[=@var{n}] -falign-loops[=@var{n}] -fassociative-math @gol
 -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize @gol
 -fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves @gol
--fcheck-data-deps -fconserve-stack -fcprop-registers -fcrossjumping @gol
+-fcheck-data-deps -fcombine-stack-adjustments -fconserve-stack @gol
+-fcprop-registers -fcrossjumping @gol
 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
 -fcx-limited-range @gol
 -fdata-sections -fdce -fdce @gol
@@ -6618,6 +6619,13 @@ 
 
 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
 
+@item -fcombine-stack-adjustments
+@opindex fcombine-stack-adjustments
+Tracks stack adjustments (pushes and pops) and stack memory references
+and then tries to find ways to combine them.
+
+Enabled by default at @option{-O1} and higher.
+
 @item -fconserve-stack
 @opindex fconserve-stack
 Attempt to minimize stack usage.  The compiler will attempt to use less
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 164830)
+++ gcc/opts.c	(working copy)
@@ -801,6 +801,7 @@ 
   flag_tree_copy_prop = opt1;
   flag_tree_sink = opt1;
   flag_tree_ch = opt1;
+  flag_combine_stack_adjustments = opt1;
 
   /* -O2 optimizations.  */
   opt2 = (optimize >= 2);
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 164830)
+++ gcc/common.opt	(working copy)
@@ -640,6 +640,10 @@ 
 Common Report Var(flag_check_data_deps)
 Compare the results of several data dependence analyzers.
 
+fcombine-stack-adjustments
+Common Report Var(flag_combine_stack_adjustments) Optimization
+Looks for opportunities to reduce stack adjustments and stack references.
+
 fcommon
 Common Report Var(flag_no_common,0) Optimization
 Do not put uninitialized globals in the common section
Index: gcc/combine-stack-adj.c
===================================================================
--- gcc/combine-stack-adj.c	(revision 164830)
+++ gcc/combine-stack-adj.c	(working copy)
@@ -546,7 +546,7 @@ 
 static bool
 gate_handle_stack_adjustments (void)
 {
-  return (optimize > 0);
+  return flag_combine_stack_adjustments;
 }
 
 static unsigned int