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-niter.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-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 116 |
1 files changed, 6 insertions, 110 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index adbfe8e..8bcb1c6 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-pass.h" + #define SWAP(X, Y) do { affine_iv *tmp = (X); (X) = (Y); (Y) = tmp; } while (0) /* The maximum number of dominator BBs we search for conditions @@ -2507,40 +2508,6 @@ derive_constant_upper_bound_ops (tree type, tree op0, } } -/* Records that every statement in LOOP is executed I_BOUND times. - REALISTIC is true if I_BOUND is expected to be close to the real number - of iterations. UPPER is true if we are sure the loop iterates at most - I_BOUND times. */ - -void -record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, - bool upper) -{ - /* Update the bounds only when there is no previous estimation, or when the - current estimation is smaller. */ - if (upper - && (!loop->any_upper_bound - || i_bound.ult (loop->nb_iterations_upper_bound))) - { - loop->any_upper_bound = true; - loop->nb_iterations_upper_bound = i_bound; - } - if (realistic - && (!loop->any_estimate - || i_bound.ult (loop->nb_iterations_estimate))) - { - loop->any_estimate = true; - loop->nb_iterations_estimate = i_bound; - } - - /* If an upper bound is smaller than the realistic estimate of the - number of iterations, use the upper bound instead. */ - if (loop->any_upper_bound - && loop->any_estimate - && loop->nb_iterations_upper_bound.ult (loop->nb_iterations_estimate)) - loop->nb_iterations_estimate = loop->nb_iterations_upper_bound; -} - /* Emit a -Waggressive-loop-optimizations warning if needed. */ static void @@ -3008,26 +2975,11 @@ infer_loop_bounds_from_undefined (struct loop *loop) free (bbs); } -/* Converts VAL to double_int. */ -static double_int -gcov_type_to_double_int (gcov_type val) -{ - double_int ret; - - ret.low = (unsigned HOST_WIDE_INT) val; - /* If HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_WIDEST_INT, avoid shifting by - the size of type. */ - val >>= HOST_BITS_PER_WIDE_INT - 1; - val >>= 1; - ret.high = (unsigned HOST_WIDE_INT) val; - - return ret; -} /* Compare double ints, callback for qsort. */ -int +static int double_int_cmp (const void *p1, const void *p2) { const double_int *d1 = (const double_int *)p1; @@ -3042,7 +2994,7 @@ double_int_cmp (const void *p1, const void *p2) /* Return index of BOUND in BOUNDS array sorted in increasing order. Lookup by binary search. */ -int +static int bound_index (vec<double_int> bounds, double_int bound) { unsigned int end = bounds.length (); @@ -3349,7 +3301,7 @@ maybe_lower_iteration_bound (struct loop *loop) /* Records estimates on numbers of iterations of LOOP. If USE_UNDEFINED_P is true also use estimates derived from undefined behavior. */ -void +static void estimate_numbers_of_iterations_loop (struct loop *loop) { vec<edge> exits; @@ -3433,21 +3385,7 @@ estimated_loop_iterations (struct loop *loop, double_int *nit) if (scev_initialized_p ()) estimate_numbers_of_iterations_loop (loop); - /* Even if the bound is not recorded, possibly we can derrive one from - profile. */ - if (!loop->any_estimate) - { - if (loop->header->count) - { - *nit = gcov_type_to_double_int - (expected_loop_iterations_unbounded (loop) + 1); - return true; - } - return false; - } - - *nit = loop->nb_iterations_estimate; - return true; + return (get_estimated_loop_iterations (loop, nit)); } /* Sets NIT to an upper bound for the maximum number of executions of the @@ -3461,31 +3399,8 @@ max_loop_iterations (struct loop *loop, double_int *nit) estimate. Otherwise just return whatever we recorded earlier. */ if (scev_initialized_p ()) estimate_numbers_of_iterations_loop (loop); - if (!loop->any_upper_bound) - return false; - - *nit = loop->nb_iterations_upper_bound; - return true; -} - -/* Similar to estimated_loop_iterations, but returns the estimate only - if it fits to HOST_WIDE_INT. If this is not the case, or the estimate - on the number of iterations of LOOP could not be derived, returns -1. */ -HOST_WIDE_INT -estimated_loop_iterations_int (struct loop *loop) -{ - double_int nit; - HOST_WIDE_INT hwi_nit; - - if (!estimated_loop_iterations (loop, &nit)) - return -1; - - if (!nit.fits_shwi ()) - return -1; - hwi_nit = nit.to_shwi (); - - return hwi_nit < 0 ? -1 : hwi_nit; + return get_max_loop_iterations (loop, nit); } /* Similar to max_loop_iterations, but returns the estimate only @@ -3508,25 +3423,6 @@ max_loop_iterations_int (struct loop *loop) return hwi_nit < 0 ? -1 : hwi_nit; } -/* Returns an upper bound on the number of executions of statements - in the LOOP. For statements before the loop exit, this exceeds - the number of execution of the latch by one. */ - -HOST_WIDE_INT -max_stmt_executions_int (struct loop *loop) -{ - HOST_WIDE_INT nit = max_loop_iterations_int (loop); - HOST_WIDE_INT snit; - - if (nit == -1) - return -1; - - snit = (HOST_WIDE_INT) ((unsigned HOST_WIDE_INT) nit + 1); - - /* If the computation overflows, return -1. */ - return snit < 0 ? -1 : snit; -} - /* Returns an estimate for the number of executions of statements in the LOOP. For statements before the loop exit, this exceeds the number of execution of the latch by one. */ |