From bb445479def5c8fcb62ba57aa917feec3228322c Mon Sep 17 00:00:00 2001 From: rakdver Date: Tue, 24 Aug 2004 20:48:23 +0000 Subject: * tree-ssa-loop-ivcanon.c: New file. * tree-ssa-loop-manip.c (create_iv): New function. * Makefile.in (tree-ssa-loop-ivcanon.o): Add. (tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency. * cfgloop.c (mark_single_exit_loops): New function. (verify_loop_structure): Verify single-exit loops. * cfgloop.h (struct loop): Add single_exit field. (LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant. (mark_single_exit_loops): Declare. (tree_num_loop_insns): Declare. * cfgloopmanip.c (update_single_exits_after_duplication): New function. (duplicate_loop_to_header_edge): Use it. * common.opt (fivcanon): New flag. * timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars. * tree-cfg.c (tree_find_edge_insert_loc): Return newly created block. (bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc. (bsi_insert_on_edge_immediate): New function. * tree-flow.h (bsi_insert_on_edge_immediate, canonicalize_induction_variables, tree_unroll_loops_completely, create_iv): Declare. * tree-optimize.c (init_tree_optimization_passes): Add pass_iv_canon and pass_complete_unroll. * tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare. * tree-scalar-evolution.c (get_loop_exit_condition, get_exit_conditions_rec, number_of_iterations_in_loop, scev_initialize): Use single_exit information. * tree-ssa-loop-niter.c (number_of_iterations_cond): Record missing assumptions. (loop_niter_by_eval): Return number of iterations as unsigned int. * tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops. (tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon, tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll): New passes. (tree_ssa_loop_done): Call free_numbers_of_iterations_estimates. * tree-ssanames.c (make_ssa_name): Allow creating ssa name before the defining statement is ready. * tree-vectorizer.c (vect_create_iv_simple): Removed. (vect_create_index_for_array_ref, vect_transform_loop_bound): Use create_iv. (vect_transform_loop_bound): Use single_exit information. (vect_analyze_loop_form): Cleanup bogus tests. (vectorize_loops): Do not call flow_loop_scan. * tree.h (may_negate_without_overflow_p): Declare. * fold-const.c (may_negate_without_overflow_p): Split out from ... (negate_expr_p): ... this function. (tree_expr_nonzero_p): Handle overflowed constants correctly. * doc/invoke.texi (-fivcanon): Document. * doc/passes.texi: Document canonical induction variable creation. * gcc.dg/tree-ssa/loop-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86516 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop.c') diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index 666dab68fa0..5b5ec05f2b4 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -101,6 +101,10 @@ tree_ssa_loop_init (void) current_loops = tree_loop_optimizer_init (dump_file); if (!current_loops) return; + + /* Find the loops that are exited just through a single edge. */ + mark_single_exit_loops (current_loops); + scev_initialize (current_loops); } @@ -187,6 +191,72 @@ struct tree_opt_pass pass_vectorize = TODO_dump_func /* todo_flags_finish */ }; +/* Canonical induction variable creation pass. */ + +static void +tree_ssa_loop_ivcanon (void) +{ + if (!current_loops) + return; + + canonicalize_induction_variables (current_loops); +} + +static bool +gate_tree_ssa_loop_ivcanon (void) +{ + return flag_ivcanon != 0; +} + +struct tree_opt_pass pass_iv_canon = +{ + "ivcanon", /* name */ + gate_tree_ssa_loop_ivcanon, /* gate */ + tree_ssa_loop_ivcanon, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_TREE_LOOP_IVCANON, /* tv_id */ + PROP_cfg | PROP_ssa, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func /* todo_flags_finish */ +}; + +/* Complete unrolling of loops. */ + +static void +tree_complete_unroll (void) +{ + if (!current_loops) + return; + + tree_unroll_loops_completely (current_loops); +} + +static bool +gate_tree_complete_unroll (void) +{ + return flag_unroll_loops != 0; +} + +struct tree_opt_pass pass_complete_unroll = +{ + "cunroll", /* name */ + gate_tree_complete_unroll, /* gate */ + tree_complete_unroll, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_COMPLETE_UNROLL, /* tv_id */ + PROP_cfg | PROP_ssa, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func /* todo_flags_finish */ +}; + /* Loop optimizer finalization. */ static void @@ -195,12 +265,12 @@ tree_ssa_loop_done (void) if (!current_loops) return; - scev_finalize (); - #ifdef ENABLE_CHECKING verify_loop_closed_ssa (); #endif + free_numbers_of_iterations_estimates (current_loops); + scev_finalize (); loop_optimizer_finalize (current_loops, (dump_flags & TDF_DETAILS ? dump_file : NULL)); current_loops = NULL; -- cgit v1.2.3