This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Enable fmove-loop-invariants by default


Hello,

> Daniel Jacobowitz wrote:
> > On Sun, Feb 26, 2006 at 07:39:25PM +0100, Zdenek Dvorak wrote:
> >> I think it is ok to apply this one for now (my one first needs to be
> >> split into several smaller parts, as I lost control over myself and
> >> removed too much at once :-)  I will send some trivial followup (for
> >> removal -fstrength-reduce and -fprefetch-loop-arrays-rtl).  I think we
> >> should then wait for a few days to make sure that we can proceed with
> >> the removal of the rest of the loop optimizer without causing some major
> >> disaster.
> > 
> > Is there a general policy on removing -f options, versus turning them
> > into NOPs?  There's a _lot_ of code lying around that references
> > -fstrength-reduce or -fno-strength-reduce.  I don't know about the
> > others like -floop-optimize, but I wouldn't be surprised.
> 
> Yes, I think we have a general policy of leaving such options around as
> no-ops, and we should certainly do so here.

I will commit the following patch that ressurects the flags as noops (as
well as cleaning up last few references to the disabled flags) as
soon as it passes testing.

Zdenek

Index: ChangeLog
===================================================================
*** ChangeLog	(revision 111461)
--- ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,20 ----
+ 2006-02-26  Zdenek Dvorak <dvorakz@suse.cz>
+ 
+ 	* opts.c (decode_options): Do not handle flag_strength_reduce.
+ 	(common_handle_option): Handle OPT_floop_optimize, OPT_frerun_loop_opt
+ 	and OPT_fstrength_reduce.
+ 	* tree-ssa-loop.c (tree_ssa_loop_prefetch): Only test
+ 	flag_prefetch_loop_arrays for being nonzero.
+ 	* common.opt (floop-optimize, frerun-loop-opt): Resurrected as
+ 	no-ops.
+ 	(fprefetch-loop-arrays-rtl): Removed.
+ 	(flag_prefetch_loop_arrays): Do not specify the value.
+ 
+ 	* doc/passes.texi: Update documentation of loop optimizer
+ 	passes.
+ 	* doc/invoke.texi (-fstrength-reduce, -fprefetch-loop-arrays-rtl,
+ 	-frerun-loop-opt): Remove.
+ 
  2006-02-26  Richard Guenther  <rguenther@suse.de>
  
  	PR tree-optimization/26421
Index: testsuite/ChangeLog
===================================================================
*** testsuite/ChangeLog	(revision 111461)
--- testsuite/ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,8 ----
+ 2006-02-26  Zdenek Dvorak <dvorakz@suse.cz>
+ 
+ 	* gcc.target/i386/20000614-2.c: Do not use -fno-strength-reduce.
+ 	* gcc.dg/20030324-1.c: Do not use -fstrength-reduce.
+ 
  2006-02-26  Richard Guenther  <rguenther@suse.de>
  
  	PR tree-optimization/26421
Index: doc/passes.texi
===================================================================
*** doc/passes.texi	(revision 111461)
--- doc/passes.texi	(working copy)
*************** are in @file{lcm.c}.
*** 574,593 ****
  
  @item Loop optimization
  
! This pass moves constant expressions out of loops, and optionally does
! strength-reduction as well.  The pass is located in @file{loop.c}.
! Loop dependency analysis routines are contained in @file{dependence.c}.
! This pass is seriously out-of-date and is supposed to be replaced by
! a new one described below in near future.
! 
! A second loop optimization pass takes care of basic block level
! optimizations---unrolling, peeling and unswitching loops.  The source
! files are @file{cfgloopanal.c} and @file{cfgloopmanip.c} containing
! generic loop analysis and manipulation code, @file{loop-init.c} with
! initialization and finalization code, @file{loop-unswitch.c} for loop
! unswitching and @file{loop-unroll.c} for loop unrolling and peeling.
! It also contains a separate loop invariant motion pass implemented in
! @file{loop-invariant.c}.
  
  @item Jump bypassing
  
--- 574,588 ----
  
  @item Loop optimization
  
! This pass performs several loop related optimizations.
! The source files @file{cfgloopanal.c} and @file{cfgloopmanip.c} contain
! generic loop analysis and manipulation code.  Initialization and finalization
! of loop structures is handled by @file{loop-init.c}.
! A loop invariant motion pass is implemented in @file{loop-invariant.c}.
! Basic block level optimizations---unrolling, peeling and unswitching loops---
! are implemented in @file{loop-unswitch.c} and @file{loop-unroll.c}.
! Replacing of the exit condition of loops by special machine-dependent
! instructions is handled by @file{loop-doloop.c}.
  
  @item Jump bypassing
  
Index: doc/invoke.texi
===================================================================
*** doc/invoke.texi	(revision 111461)
--- doc/invoke.texi	(working copy)
*************** the directories are searched in the orde
*** 107,113 ****
  
  Many options have long names starting with @samp{-f} or with
  @samp{-W}---for example, 
! @option{-fstrength-reduce}, @option{-Wformat} and so on.  Most of
  these have both positive and negative forms; the negative form of
  @option{-ffoo} would be @option{-fno-foo}.  This manual documents
  only one of these two forms, whichever one is not the default.
--- 107,113 ----
  
  Many options have long names starting with @samp{-f} or with
  @samp{-W}---for example, 
! @option{-fmove-loop-invariants}, @option{-Wformat} and so on.  Most of
  these have both positive and negative forms; the negative form of
  @option{-ffoo} would be @option{-fno-foo}.  This manual documents
  only one of these two forms, whichever one is not the default.
*************** Objective-C and Objective-C++ Dialects}.
*** 321,331 ****
  -funsafe-math-optimizations  -funsafe-loop-optimizations  -ffinite-math-only @gol
  -fno-toplevel-reorder -fno-trapping-math  -fno-zero-initialized-in-bss @gol
  -fomit-frame-pointer  -foptimize-register-move @gol
! -foptimize-sibling-calls  -fprefetch-loop-arrays -fprefetch-loop-arrays-rtl @gol
  -fprofile-generate -fprofile-use @gol
  -fregmove  -frename-registers @gol
  -freorder-blocks  -freorder-blocks-and-partition -freorder-functions @gol
! -frerun-cse-after-loop  -frerun-loop-opt @gol
  -frounding-math -frtl-abstract-sequences @gol
  -fschedule-insns  -fschedule-insns2 @gol
  -fno-sched-interblock  -fno-sched-spec  -fsched-spec-load @gol
--- 321,331 ----
  -funsafe-math-optimizations  -funsafe-loop-optimizations  -ffinite-math-only @gol
  -fno-toplevel-reorder -fno-trapping-math  -fno-zero-initialized-in-bss @gol
  -fomit-frame-pointer  -foptimize-register-move @gol
! -foptimize-sibling-calls  -fprefetch-loop-arrays @gol
  -fprofile-generate -fprofile-use @gol
  -fregmove  -frename-registers @gol
  -freorder-blocks  -freorder-blocks-and-partition -freorder-functions @gol
! -frerun-cse-after-loop @gol
  -frounding-math -frtl-abstract-sequences @gol
  -fschedule-insns  -fschedule-insns2 @gol
  -fno-sched-interblock  -fno-sched-spec  -fsched-spec-load @gol
*************** Objective-C and Objective-C++ Dialects}.
*** 335,341 ****
  -fsched2-use-traces -freschedule-modulo-scheduled-loops @gol
  -fsection-anchors  -fsignaling-nans  -fsingle-precision-constant @gol
  -fstack-protector  -fstack-protector-all @gol
! -fstrength-reduce  -fstrict-aliasing  -ftracer  -fthread-jumps @gol
  -funroll-all-loops  -funroll-loops  -fpeel-loops @gol
  -fsplit-ivs-in-unroller -funswitch-loops @gol
  -fvariable-expansion-in-unroller @gol
--- 335,341 ----
  -fsched2-use-traces -freschedule-modulo-scheduled-loops @gol
  -fsection-anchors  -fsignaling-nans  -fsingle-precision-constant @gol
  -fstack-protector  -fstack-protector-all @gol
! -fstrict-aliasing  -ftracer  -fthread-jumps @gol
  -funroll-all-loops  -funroll-loops  -fpeel-loops @gol
  -fsplit-ivs-in-unroller -funswitch-loops @gol
  -fvariable-expansion-in-unroller @gol
*************** also turns on the following optimization
*** 4434,4441 ****
  -fcse-follow-jumps  -fcse-skip-blocks @gol
  -fgcse  -fgcse-lm  @gol
  -fexpensive-optimizations @gol
! -fstrength-reduce @gol
! -frerun-cse-after-loop  -frerun-loop-opt @gol
  -fcaller-saves @gol
  -fpeephole2 @gol
  -fschedule-insns  -fschedule-insns2 @gol
--- 4434,4440 ----
  -fcse-follow-jumps  -fcse-skip-blocks @gol
  -fgcse  -fgcse-lm  @gol
  -fexpensive-optimizations @gol
! -frerun-cse-after-loop  @gol
  -fcaller-saves @gol
  -fpeephole2 @gol
  -fschedule-insns  -fschedule-insns2 @gol
*************** register, compare it against zero, then 
*** 4670,4677 ****
  This option is only meaningful on architectures that support such
  instructions, which include x86, PowerPC, IA-64 and S/390.
  
! The default is @option{-fbranch-count-reg}, enabled when
! @option{-fstrength-reduce} is enabled.
  
  @item -fno-function-cse
  @opindex fno-function-cse
--- 4669,4675 ----
  This option is only meaningful on architectures that support such
  instructions, which include x86, PowerPC, IA-64 and S/390.
  
! The default is @option{-fbranch-count-reg}.
  
  @item -fno-function-cse
  @opindex fno-function-cse
*************** instrumentation (and therefore faster ex
*** 4730,4742 ****
  some protection against outright memory corrupting writes, but allows
  erroneously read data to propagate within a program.
  
- @item -fstrength-reduce
- @opindex fstrength-reduce
- Perform the optimizations of loop strength reduction and
- elimination of iteration variables.
- 
- Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
- 
  @item -fthread-jumps
  @opindex fthread-jumps
  Perform optimizations where we check to see if a jump branches to a
--- 4728,4733 ----
*************** better job.
*** 5130,5138 ****
  @item -funroll-loops
  @opindex funroll-loops
  Unroll loops whose number of iterations can be determined at compile
! time or upon entry to the loop.  @option{-funroll-loops} implies both
! @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}.  This
! option makes code larger, and may or may not make it run faster.
  
  @item -funroll-all-loops
  @opindex funroll-all-loops
--- 5121,5129 ----
  @item -funroll-loops
  @opindex funroll-loops
  Unroll loops whose number of iterations can be determined at compile
! time or upon entry to the loop.  @option{-funroll-loops} implies
! @option{-frerun-cse-after-loop}.  This option makes code larger,
! and may or may not make it run faster.
  
  @item -funroll-all-loops
  @opindex funroll-all-loops
*************** With this option, the compiler will crea
*** 5160,5174 ****
  local variables when unrolling a loop which can result in superior code.
  
  @item -fprefetch-loop-arrays
- @itemx -fprefetch-loop-arrays-rtl
  @opindex fprefetch-loop-arrays
- @opindex fprefetch-loop-arrays-rtl
  If supported by the target machine, generate instructions to prefetch
  memory to improve the performance of loops that access large arrays.
  
! These options may generate better or worse code; results are highly
  dependent on the structure of loops within the source code.
  
  @item -fno-peephole
  @itemx -fno-peephole2
  @opindex fno-peephole
--- 5151,5165 ----
  local variables when unrolling a loop which can result in superior code.
  
  @item -fprefetch-loop-arrays
  @opindex fprefetch-loop-arrays
  If supported by the target machine, generate instructions to prefetch
  memory to improve the performance of loops that access large arrays.
  
! This option may generate better or worse code; results are highly
  dependent on the structure of loops within the source code.
  
+ Disabled at level @option{-Os}.
+ 
  @item -fno-peephole
  @itemx -fno-peephole2
  @opindex fno-peephole
*************** at level @option{-O1}
*** 5698,5712 ****
  Move branches with loop invariant conditions out of the loop, with duplicates
  of the loop on both branches (modified according to result of the condition).
  
- @item -fprefetch-loop-arrays
- @itemx -fprefetch-loop-arrays-rtl
- @opindex fprefetch-loop-arrays
- @opindex fprefetch-loop-arrays-rtl
- If supported by the target machine, generate instructions to prefetch
- memory to improve the performance of loops that access large arrays.
- 
- Disabled at level @option{-Os}.
- 
  @item -ffunction-sections
  @itemx -fdata-sections
  @opindex ffunction-sections
--- 5689,5694 ----
Index: testsuite/gcc.target/i386/20000614-2.c
===================================================================
*** testsuite/gcc.target/i386/20000614-2.c	(revision 111461)
--- testsuite/gcc.target/i386/20000614-2.c	(working copy)
***************
*** 1,5 ****
  /* { dg-do run { target i?86-*-* x86_64-*-*} } */
! /* { dg-options "-O2 -fno-strength-reduce" } */
  
  extern void abort (void);
  extern void exit (int);
--- 1,5 ----
  /* { dg-do run { target i?86-*-* x86_64-*-*} } */
! /* { dg-options "-O2" } */
  
  extern void abort (void);
  extern void exit (int);
Index: testsuite/gcc.dg/20030324-1.c
===================================================================
*** testsuite/gcc.dg/20030324-1.c	(revision 111461)
--- testsuite/gcc.dg/20030324-1.c	(working copy)
***************
*** 1,5 ****
  /* { dg-do run } */
! /* { dg-options "-O -fstrength-reduce -fstrict-aliasing -fgcse" } */
  
  /* PR optimization/10087 */
  /* Contributed by Peter van Hoof <p.van-hoof@qub.ac.uk> */
--- 1,5 ----
  /* { dg-do run } */
! /* { dg-options "-O -fstrict-aliasing -fgcse" } */
  
  /* PR optimization/10087 */
  /* Contributed by Peter van Hoof <p.van-hoof@qub.ac.uk> */
Index: opts.c
===================================================================
*** opts.c	(revision 111461)
--- opts.c	(working copy)
*************** decode_options (unsigned int argc, const
*** 564,570 ****
        flag_gcse = 1;
        flag_expensive_optimizations = 1;
        flag_ipa_type_escape = 1;
-       flag_strength_reduce = 1;
        flag_rerun_cse_after_loop = 1;
        flag_caller_saves = 1;
        flag_peephole2 = 1;
--- 564,569 ----
*************** common_handle_option (size_t scode, cons
*** 1083,1088 ****
--- 1082,1093 ----
        warning (0, "-f[no-]force-mem is nop and option will be removed in 4.2");
        break;
  
+     case OPT_floop_optimize:
+     case OPT_frerun_loop_opt:
+     case OPT_fstrength_reduce:
+       /* These are no-ops, preserved for backward compatability.  */
+       break;
+ 
      default:
        /* If the flag was handled in a standard way, assume the lack of
  	 processing here is intentional.  */
Index: tree-ssa-loop.c
===================================================================
*** tree-ssa-loop.c	(revision 111461)
--- tree-ssa-loop.c	(working copy)
*************** tree_ssa_loop_prefetch (void)
*** 416,422 ****
  static bool
  gate_tree_ssa_loop_prefetch (void)
  {
!   return flag_prefetch_loop_arrays == 1;
  }
  
  struct tree_opt_pass pass_loop_prefetch =
--- 416,422 ----
  static bool
  gate_tree_ssa_loop_prefetch (void)
  {
!   return flag_prefetch_loop_arrays != 0;
  }
  
  struct tree_opt_pass pass_loop_prefetch =
Index: common.opt
===================================================================
*** common.opt	(revision 111461)
--- common.opt	(working copy)
*************** fleading-underscore
*** 555,560 ****
--- 555,564 ----
  Common Report Var(flag_leading_underscore) Init(-1)
  Give external symbols a leading underscore
  
+ floop-optimize
+ Common
+ Does nothing.  Preserved for backward compatability.
+ 
  fmath-errno
  Common Report Var(flag_errno_math) Init(1)
  Set errno after built-in math functions
*************** Common Report Var(flag_pie,1) VarExists
*** 659,669 ****
  Generate position-independent code for executables if possible (small mode)
  
  fprefetch-loop-arrays
! Common Report Var(flag_prefetch_loop_arrays,1)
! Generate prefetch instructions, if available, for arrays in loops
! 
! fprefetch-loop-arrays-rtl
! Common Report Var(flag_prefetch_loop_arrays,2)
  Generate prefetch instructions, if available, for arrays in loops
  
  fprofile
--- 663,669 ----
  Generate position-independent code for executables if possible (small mode)
  
  fprefetch-loop-arrays
! Common Report Var(flag_prefetch_loop_arrays)
  Generate prefetch instructions, if available, for arrays in loops
  
  fprofile
*************** frerun-cse-after-loop
*** 721,726 ****
--- 721,730 ----
  Common Report Var(flag_rerun_cse_after_loop) Init(2)
  Add a common subexpression elimination pass after loop optimizations
  
+ frerun-loop-opt
+ Common
+ Does nothing.  Preserved for backward compatability.
+ 
  frounding-math
  Common Report Var(flag_rounding_math)
  Disable optimizations that assume default FP rounding behavior
*************** Common Report RejectNegative Var(flag_st
*** 837,844 ****
  Use a stack protection method for every function
  
  fstrength-reduce
! Common Report Var(flag_strength_reduce)
! Perform strength reduction optimizations
  
  ; Nonzero if we should do (language-dependent) alias analysis.
  ; Typically, this analysis will assume that expressions of certain
--- 841,848 ----
  Use a stack protection method for every function
  
  fstrength-reduce
! Common
! Does nothing.  Preserved for backward compatability.
  
  ; Nonzero if we should do (language-dependent) alias analysis.
  ; Typically, this analysis will assume that expressions of certain


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]