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]

[PATCH] Fix PR18754: add early loop pass, 2nd try


On Thu, 20 Jan 2005, Richard Guenther wrote:

> Hi!
>
> This patch adds an early loop pass (just after ch) just
> containing complete unrolling.  This allows the following
> SRA pass to scalarize small arrays that were manipulated
> in constant rolling loops, as it often happens in C++ code.

Merely the same as before, but guarded with -ftree-early-loop-optimize
and proper documentation.  Disabled by default.

Bootstrapped on ia32, ok?  If yes, please apply.

Thanks,
Richard.


2005-Jan-20  Richard Guenther <richard.guenther@uni-tuebingen.de>

	PR tree-optimization/18754
	* doc/invoke.texi: document -ftree-early-loop-optimize.
	common.opt: new option -ftree-early-loop-optimize.
	tree-optimize.c (init_tree_optimization_passes):
	schedule loop0 between ch and sra.
	tree-pass.h: declare pass_loop0.
	tree-ssa-loop.c: define pass_loop0,
	(gate_loop0): new.


Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.568
diff -u -c -3 -p -r1.568 invoke.texi
*** doc/invoke.texi	18 Jan 2005 06:03:46 -0000	1.568
--- doc/invoke.texi	20 Jan 2005 12:08:12 -0000
*************** Objective-C and Objective-C++ Dialects}.
*** 317,325 ****
  -funroll-all-loops  -funroll-loops  -fpeel-loops @gol
  -fsplit-ivs-in-unroller -funswitch-loops @gol
  -fvariable-expansion-in-unroller @gol
! -ftree-pre  -ftree-ccp  -ftree-dce -ftree-loop-optimize @gol
! -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts @gol
! -ftree-dominator-opts -ftree-dse -ftree-copyrename @gol
  -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize @gol
  --param @var{name}=@var{value}
  -O  -O0  -O1  -O2  -O3  -Os}
--- 317,325 ----
  -funroll-all-loops  -funroll-loops  -fpeel-loops @gol
  -fsplit-ivs-in-unroller -funswitch-loops @gol
  -fvariable-expansion-in-unroller @gol
! -ftree-pre  -ftree-ccp  -ftree-dce -ftree-early-loop-optimize @gol
! -ftree-loop-optimize -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon @gol
! -fivopts -ftree-dominator-opts -ftree-dse -ftree-copyrename @gol
  -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize @gol
  --param @var{name}=@var{value}
  -O  -O0  -O1  -O2  -O3  -Os}
*************** effectiveness of code motion optimizatio
*** 4655,4660 ****
--- 4655,4667 ----
  is enabled by default at @option{-O} and higher.  It is not enabled
  for @option{-Os}, since it usually increases code size.

+ @item -ftree-early-loop-optimize
+ Perform an early loop optimization pass on trees.  Early loop optimization
+ tries to get rid of artificial loops running a compile-time constant number
+ of iterations.  For this flag to be effective you may need to enable
+ loop peeling or loop unrolling.  Early loop optimization may inhibit
+ vectorization of some loops.  This flag is disabled by default.
+
  @item -ftree-loop-optimize
  Perform loop optimizations on trees.  This flag is enabled by default
  at @option{-O} and higher.
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.68
diff -u -c -3 -p -r2.68 tree-optimize.c
*** tree-optimize.c	18 Jan 2005 11:36:24 -0000	2.68
--- tree-optimize.c	20 Jan 2005 12:08:12 -0000
*************** init_tree_optimization_passes (void)
*** 359,364 ****
--- 359,365 ----
    NEXT_PASS (pass_may_alias);
    NEXT_PASS (pass_tail_recursion);
    NEXT_PASS (pass_ch);
+   NEXT_PASS (pass_loop0);
    NEXT_PASS (pass_profile);
    NEXT_PASS (pass_sra);
    NEXT_PASS (pass_rename_ssa_copies);
*************** init_tree_optimization_passes (void)
*** 403,408 ****
--- 404,417 ----
    NEXT_PASS (pass_cleanup_cfg_post_optimizing);
    *p = NULL;

+   p = &pass_loop0.sub;
+   NEXT_PASS (pass_loop_init);
+   NEXT_PASS (pass_complete_unroll);
+   NEXT_PASS (pass_loop_done);
+   NEXT_PASS (pass_dominator);
+   NEXT_PASS (pass_redundant_phi);
+   *p = NULL;
+
    p = &pass_loop.sub;
    NEXT_PASS (pass_loop_init);
    NEXT_PASS (pass_lim);
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pass.h,v
retrieving revision 2.24
diff -u -c -3 -p -r2.24 tree-pass.h
*** tree-pass.h	18 Jan 2005 11:36:26 -0000	2.24
--- tree-pass.h	20 Jan 2005 12:08:12 -0000
*************** extern struct tree_opt_pass pass_referen
*** 124,129 ****
--- 124,130 ----
  extern struct tree_opt_pass pass_sra;
  extern struct tree_opt_pass pass_tail_recursion;
  extern struct tree_opt_pass pass_tail_calls;
+ extern struct tree_opt_pass pass_loop0;
  extern struct tree_opt_pass pass_loop;
  extern struct tree_opt_pass pass_loop_init;
  extern struct tree_opt_pass pass_lim;
Index: tree-ssa-loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop.c,v
retrieving revision 2.23
diff -u -c -3 -p -r2.23 tree-ssa-loop.c
*** tree-ssa-loop.c	26 Nov 2004 06:42:25 -0000	2.23
--- tree-ssa-loop.c	20 Jan 2005 12:08:12 -0000
*************** tree_loop_optimizer_init (FILE *dump)
*** 68,73 ****
--- 68,98 ----
    return loops;
  }

+ /* The loop0 superpass.  */
+
+ static bool
+ gate_loop0 (void)
+ {
+   return flag_tree_early_loop_optimize != 0;
+ }
+
+ struct tree_opt_pass pass_loop0 =
+ {
+   "loop",				/* name */
+   gate_loop0,				/* gate */
+   NULL,					/* execute */
+   NULL,					/* sub */
+   NULL,					/* next */
+   0,					/* static_pass_number */
+   TV_TREE_LOOP,				/* tv_id */
+   PROP_cfg,				/* properties_required */
+   0,					/* properties_provided */
+   0,					/* properties_destroyed */
+   TODO_ggc_collect,			/* todo_flags_start */
+   TODO_dump_func | TODO_verify_ssa | TODO_ggc_collect,	/* todo_flags_finish */
+   0					/* letter */
+ };
+
  /* The loop superpass.  */

  static bool
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.60
diff -u -c -3 -p -r1.60 common.opt
*** common.opt	17 Jan 2005 09:37:56 -0000	1.60
--- common.opt	20 Jan 2005 12:08:12 -0000
*************** ftree-dse
*** 844,849 ****
--- 844,853 ----
  Common Report Var(flag_tree_dse)
  Enable dead store elimination

+ ftree-early-loop-optimize
+ Common Report Var(flag_tree_early_loop_optimize) Init(0)
+ Enable loop optimizations on tree level
+
  ftree-fre
  Common Report Var(flag_tree_fre)
  Enable Full Redundancy Elimination (FRE) on trees


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