This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Enable record_bounds pass
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 13 Sep 2004 08:34:33 +0200
- Subject: [patch] Enable record_bounds pass
Hello,
this pass records estimates on number of iterations of a loop.
This may enable the ivopts to decide that a value that is
zero/sign extended is an induction variable (i.e. that the value
does not overflow in the shorter mode), and optimize it
(often removing the zero/sign extend in the process).
This is a must-have on architectures where
sizeof (int) != sizeof (void *), since there basically every
array access contains such a zero extend.
Bootstrapped & regtested on i686 and x86_64.
Zdenek
* tree-optimize.c (init_tree_optimization_passes): Add
pass_record_bounds.
* tree-pass.h (pass_record_bounds): Declare.
* tree-ssa-loop.c (tree_ssa_loop_bounds, pass_record_bounds):
New pass.
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.45
diff -c -3 -p -r2.45 tree-optimize.c
*** tree-optimize.c 9 Sep 2004 20:53:36 -0000 2.45
--- tree-optimize.c 11 Sep 2004 19:44:56 -0000
*************** init_tree_optimization_passes (void)
*** 392,397 ****
--- 392,398 ----
NEXT_PASS (pass_loop_init);
NEXT_PASS (pass_lim);
NEXT_PASS (pass_iv_canon);
+ NEXT_PASS (pass_record_bounds);
NEXT_PASS (pass_if_conversion);
NEXT_PASS (pass_vectorize);
NEXT_PASS (pass_linear_transform);
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pass.h,v
retrieving revision 2.15
diff -c -3 -p -r2.15 tree-pass.h
*** tree-pass.h 9 Sep 2004 20:53:37 -0000 2.15
--- tree-pass.h 11 Sep 2004 19:44:56 -0000
*************** extern struct tree_opt_pass pass_loop;
*** 126,131 ****
--- 126,132 ----
extern struct tree_opt_pass pass_loop_init;
extern struct tree_opt_pass pass_lim;
extern struct tree_opt_pass pass_iv_canon;
+ extern struct tree_opt_pass pass_record_bounds;
extern struct tree_opt_pass pass_if_conversion;
extern struct tree_opt_pass pass_vectorize;
extern struct tree_opt_pass pass_complete_unroll;
Index: tree-ssa-loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop.c,v
retrieving revision 2.17
diff -c -3 -p -r2.17 tree-ssa-loop.c
*** tree-ssa-loop.c 8 Sep 2004 15:28:56 -0000 2.17
--- tree-ssa-loop.c 11 Sep 2004 19:44:57 -0000
*************** struct tree_opt_pass pass_iv_canon =
*** 263,268 ****
--- 263,297 ----
0 /* letter */
};
+ /* Record bounds on numbers of iterations of loops. */
+
+ static void
+ tree_ssa_loop_bounds (void)
+ {
+ if (!current_loops)
+ return;
+
+ estimate_numbers_of_iterations (current_loops);
+ scev_reset ();
+ }
+
+ struct tree_opt_pass pass_record_bounds =
+ {
+ "bounds", /* name */
+ NULL, /* gate */
+ tree_ssa_loop_bounds, /* execute */
+ NULL, /* sub */
+ NULL, /* next */
+ 0, /* static_pass_number */
+ 0, /* tv_id */
+ PROP_cfg | PROP_ssa, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0, /* todo_flags_finish */
+ 0 /* letter */
+ };
+
/* Complete unrolling of loops. */
static void