aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2012-10-08 20:09:41 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2012-10-08 18:09:41 +0000
commite3a8f1fa88d6d87444489c5cf8100aeb09bfb179 (patch)
treeeb195a552c62fbc24735e6506d9aa729f6806b75 /gcc/tree-ssa-loop-niter.c
parentee84cd3713c1246afc473ae4acc9b6e061c206fe (diff)
downloadgcc-e3a8f1fa88d6d87444489c5cf8100aeb09bfb179.zip
gcc-e3a8f1fa88d6d87444489c5cf8100aeb09bfb179.tar.gz
gcc-e3a8f1fa88d6d87444489c5cf8100aeb09bfb179.tar.bz2
loop-unswitch.c (unswitch_single_loop): Use estimated_loop_iterations_int to prevent unswitching when...
* loop-unswitch.c (unswitch_single_loop): Use estimated_loop_iterations_int to prevent unswitching when loop is known to not roll. * tree-ssa-loop-niter.c (estimated_loop_iterations): Do not segfault when SCEV is not initialized. (max_loop_iterations): Likewise. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Use estimated_loop_iterations_int to prevent unswithcing when loop is known to not roll. * tree-scalar-evolution.c (scev_initialized_p): New function. * tree-scalar-evolution.h (scev_initialized_p): Likewise. * loop-unroll.c (decide_peel_once_rolling): Use max_loop_iterations_int. (unroll_loop_constant_iterations): Update nb_iterations_upper_bound and nb_iterations_estimate. (decide_unroll_runtime_iterations): Use estimated_loop_iterations or max_loop_iterations; (unroll_loop_runtime_iterations): fix profile updating. (decide_peel_simple): Use estimated_loop_iterations and max_loop_iterations. (decide_unroll_stupid): Use estimated_loop_iterations ad max_loop_iterations. * loop-doloop.c (doloop_modify): Use max_loop_iterations_int. (doloop_optimize): Likewise. * loop-iv.c (iv_number_of_iterations): Use record_niter_bound. (find_simple_exit): Likewise. * cfgloop.h (struct niter_desc): Remove niter_max. From-SVN: r192219
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 84ae610..cdcdb5c 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3012,9 +3012,23 @@ estimate_numbers_of_iterations_loop (struct loop *loop)
bool
estimated_loop_iterations (struct loop *loop, double_int *nit)
{
- estimate_numbers_of_iterations_loop (loop);
+ /* When SCEV information is available, try to update loop iterations
+ estimate. Otherwise just return whatever we recorded earlier. */
+ 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)
- return false;
+ {
+ 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;
@@ -3027,7 +3041,10 @@ estimated_loop_iterations (struct loop *loop, double_int *nit)
bool
max_loop_iterations (struct loop *loop, double_int *nit)
{
- estimate_numbers_of_iterations_loop (loop);
+ /* When SCEV information is available, try to update loop iterations
+ 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;