diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2013-10-09 13:09:23 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2013-10-09 13:09:23 +0000 |
commit | 713438778be52a0cb0533fad271c05481435b519 (patch) | |
tree | daafe0156356e7c30b23700b33e51ef2d3acc1a2 /gcc/tree-ssa-loop-ivcanon.c | |
parent | 826cacfe24c4643799d85f07b25d15a0d3b76bc0 (diff) | |
download | gcc-713438778be52a0cb0533fad271c05481435b519.zip gcc-713438778be52a0cb0533fad271c05481435b519.tar.gz gcc-713438778be52a0cb0533fad271c05481435b519.tar.bz2 |
tree-flow.h: Move some protoypes.
* tree-flow.h: Move some protoypes. Include new tree-ssa-loop.h.
(struct affine_iv, struct tree_niter_desc): Move to tree-ssa-loop.h.
(enum move_pos): Move to tree-ssa-loop-im.h
* cfgloop.h: Move some prototypes.
(gcov_type_to_double_int): relocate from tree-ssa-loop.niter.c.
* tree-flow-inline.h (loop_containing_stmt): Move to tree-ssa-loop.h.
* tree-ssa-loop.h: New File. Include other tree-ssa-loop-*.h files.
(struct affine_iv, struct tree_niter_desc): Relocate from tree-flow.h.
(loop_containing_stmt): Relocate from tree-flow-inline.h.
* tree-ssa-loop-ch.c: (do_while_loop_p): Make static.
* tree-ssa-loop-im.c (for_each_index): Move to tree-ssa-loop.c.
(enum move_pos): Relocate here.
(lsm_tmp_name_add, gen_lsm_tmp_name, get_lsm_tmp_name): Move to
tree-ssa-loop.c.
(execute_sm_if_changed_flag_set): Change get_lsm_tmp_name call.
(tree_ssa_loop_im, gate_tree_ssa_loop_im, pass_data_lim, make_pass_lim):
Relocate here from tree-ssa-loop.c.
* tree-ssa-loop-ivcanon.c (tree_num_loop_insns): Move to
tree-ssa-loop.c.
(loop_edge_to_cancel, unloop_loops): Make static.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_data_iv_canon,
make_pass_iv_canon): Relocate from tree-ssa-loop.c.
(tree_complete_unroll, gate_tree_complete_unroll,
pass_data_complete_unroll, make_pass_complete_unroll): Relocate here.
(tree_complete_unroll_inner, gate_tree_complete_unroll_inner,
pass_data_complete_unrolli, make_pass_complete_unrolli): Relocate here.
* tree-ssa-loop-ivopts.c: Remove local prototypes.
(stmt_invariant_in_loop_p): Remove unused function.
* tree-ssa-loop-ivopts.h: New file. Add prototypes.
* tree-ssa-loop-manip.h: New file. Add prototypes.
* tree-ssa-loop-niter.c (record_niter_bound): Move to cfgloop.c.
(gcov_type_to_double_int): Move to cfgloop.h.
(double_int_cmp, bound_index,
estimate_numbers_of_iterations_loop): Make static.
(estimated_loop_iterations): Factor out get_estimated_loop_iterations.
(max_loop_iterations): Factor out get_max_loop_iterations.
(estimated_loop_iterations_int, max_stmt_executions_int): Move to
cfgloop.c.
* tree-ssa-loop-niter.h: New file. Add prototypes.
* tree-ssa-loop-prefetch.c (tree_ssa_loop_prefetch,
gate_tree_ssa_loop_prefetch, pass_data_loop_prefetch,
make_pass_loop_prefetch): Relocate from tree-ssa-loop.c.
* tree-ssa-loop-unswitch.c (tree_ssa_loop_unswitch,
gate_tree_ssa_loop_unswitch, pass_data_tree_unswitch,
make_pass_tree_unswitch): Relocate from tree-ssa-loop.c.
* tree-ssa-loop.c (tree_ssa_loop_im, gate_tree_ssa_loop_im,
pass_data_lim, make_pass_lim): Move to tree-ssa-loop-im.c.
(tree_ssa_loop_unswitch, gate_tree_ssa_loop_unswitch,
pass_data_tree_unswitch, make_pass_tree_unswitch): Move.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_data_iv_canon,
make_pass_iv_canon, tree_complete_unroll, gate_tree_complete_unroll,
pass_data_complete_unroll, make_pass_complete_unroll,
tree_complete_unroll_inner, gate_tree_complete_unroll_inner,
pass_data_complete_unrolli, make_pass_complete_unrolli): Move to
tree-ssa-loop-ivcanon.c.
(tree_ssa_loop_prefetch, gate_tree_ssa_loop_prefetch,
pass_data_loop_prefetch, make_pass_loop_prefetch): Move to
tree-ssa-loop-prefetch.c.
(for_each_index, lsm_tmp_name_add, gen_lsm_tmp_name): Relocate from
tree-ssa-loop-im.c.
(get_lsm_tmp_name): Relocate and add suffix parameter.
(tree_num_loop_insns): Relocate from tree-ssa-ivcanon.c.
* tree-scalar-evolution.h (simple_iv): Don't use affive_iv typedef.
* cfgloop.c (record_niter_bound, estimated_loop_iterations_int,
max_stmt_executions_int): Move from tree-ssa-loop-niter.c.
(get_estimated_loop_iterations): Factor out accessor from
estimated_loop_iterations in tree-ssa-loop-niter.c.
(get_max_loop_iterations): Factor out accessor from _max_loop_iterations
in tree-ssa-niter.c.
* loop-unroll.c (decide_unroll_constant_iterations,
decide_unroll_runtime_iterations, decide_peel_simple,
decide_unroll_stupid): Use new get_* accessors.
From-SVN: r203317
Diffstat (limited to 'gcc/tree-ssa-loop-ivcanon.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivcanon.c | 200 |
1 files changed, 181 insertions, 19 deletions
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index d5249ba..8db5b9e 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -107,23 +107,6 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter) update_stmt (cond); } -/* Computes an estimated number of insns in LOOP, weighted by WEIGHTS. */ - -unsigned -tree_num_loop_insns (struct loop *loop, eni_weights *weights) -{ - basic_block *body = get_loop_body (loop); - gimple_stmt_iterator gsi; - unsigned size = 0, i; - - for (i = 0; i < loop->num_nodes; i++) - for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi)) - size += estimate_num_insns (gsi_stmt (gsi), weights); - free (body); - - return size; -} - /* Describe size of loop as detected by tree_estimate_loop_size. */ struct loop_size { @@ -422,7 +405,7 @@ estimated_unrolled_size (struct loop_size *size, loop-niter identified as having undefined effect in the last iteration. The other cases are hopefully rare and will be cleaned up later. */ -edge +static edge loop_edge_to_cancel (struct loop *loop) { vec<edge> exits; @@ -598,7 +581,7 @@ static vec<int> loops_to_unloop_nunroll; LOOP_CLOSED_SSA_INVALIDATED is used to bookkepp the case when we need to go into loop closed SSA form. */ -void +static void unloop_loops (bitmap loop_closed_ssa_invalidated, bool *irred_invalidated) { @@ -1253,3 +1236,182 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer) return 0; } + +/* Canonical induction variable creation pass. */ + +static unsigned int +tree_ssa_loop_ivcanon (void) +{ + if (number_of_loops (cfun) <= 1) + return 0; + + return canonicalize_induction_variables (); +} + +static bool +gate_tree_ssa_loop_ivcanon (void) +{ + return flag_tree_loop_ivcanon != 0; +} + +namespace { + +const pass_data pass_data_iv_canon = +{ + GIMPLE_PASS, /* type */ + "ivcanon", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + true, /* has_gate */ + true, /* has_execute */ + TV_TREE_LOOP_IVCANON, /* tv_id */ + ( PROP_cfg | PROP_ssa ), /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_iv_canon : public gimple_opt_pass +{ +public: + pass_iv_canon (gcc::context *ctxt) + : gimple_opt_pass (pass_data_iv_canon, ctxt) + {} + + /* opt_pass methods: */ + bool gate () { return gate_tree_ssa_loop_ivcanon (); } + unsigned int execute () { return tree_ssa_loop_ivcanon (); } + +}; // class pass_iv_canon + +} // anon namespace + +gimple_opt_pass * +make_pass_iv_canon (gcc::context *ctxt) +{ + return new pass_iv_canon (ctxt); +} + +/* Complete unrolling of loops. */ + +static unsigned int +tree_complete_unroll (void) +{ + if (number_of_loops (cfun) <= 1) + return 0; + + return tree_unroll_loops_completely (flag_unroll_loops + || flag_peel_loops + || optimize >= 3, true); +} + +static bool +gate_tree_complete_unroll (void) +{ + return true; +} + +namespace { + +const pass_data pass_data_complete_unroll = +{ + GIMPLE_PASS, /* type */ + "cunroll", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + true, /* has_gate */ + true, /* has_execute */ + TV_COMPLETE_UNROLL, /* tv_id */ + ( PROP_cfg | PROP_ssa ), /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_complete_unroll : public gimple_opt_pass +{ +public: + pass_complete_unroll (gcc::context *ctxt) + : gimple_opt_pass (pass_data_complete_unroll, ctxt) + {} + + /* opt_pass methods: */ + bool gate () { return gate_tree_complete_unroll (); } + unsigned int execute () { return tree_complete_unroll (); } + +}; // class pass_complete_unroll + +} // anon namespace + +gimple_opt_pass * +make_pass_complete_unroll (gcc::context *ctxt) +{ + return new pass_complete_unroll (ctxt); +} + +/* Complete unrolling of inner loops. */ + +static unsigned int +tree_complete_unroll_inner (void) +{ + unsigned ret = 0; + + loop_optimizer_init (LOOPS_NORMAL + | LOOPS_HAVE_RECORDED_EXITS); + if (number_of_loops (cfun) > 1) + { + scev_initialize (); + ret = tree_unroll_loops_completely (optimize >= 3, false); + free_numbers_of_iterations_estimates (); + scev_finalize (); + } + loop_optimizer_finalize (); + + return ret; +} + +static bool +gate_tree_complete_unroll_inner (void) +{ + return optimize >= 2; +} + +namespace { + +const pass_data pass_data_complete_unrolli = +{ + GIMPLE_PASS, /* type */ + "cunrolli", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + true, /* has_gate */ + true, /* has_execute */ + TV_COMPLETE_UNROLL, /* tv_id */ + ( PROP_cfg | PROP_ssa ), /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_verify_flow, /* todo_flags_finish */ +}; + +class pass_complete_unrolli : public gimple_opt_pass +{ +public: + pass_complete_unrolli (gcc::context *ctxt) + : gimple_opt_pass (pass_data_complete_unrolli, ctxt) + {} + + /* opt_pass methods: */ + bool gate () { return gate_tree_complete_unroll_inner (); } + unsigned int execute () { return tree_complete_unroll_inner (); } + +}; // class pass_complete_unrolli + +} // anon namespace + +gimple_opt_pass * +make_pass_complete_unrolli (gcc::context *ctxt) +{ + return new pass_complete_unrolli (ctxt); +} + + |