summaryrefslogtreecommitdiff
path: root/gcc/loop-doloop.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-08 18:09:41 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-08 18:09:41 +0000
commita9ef98778deaf3b83ca1349ad09e7b15ce908158 (patch)
treeeb195a552c62fbc24735e6506d9aa729f6806b75 /gcc/loop-doloop.c
parent514d377a3dcb7aeb49113b23d70fc87f6304a30e (diff)
downloadgcc-a9ef98778deaf3b83ca1349ad09e7b15ce908158.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192219 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-doloop.c')
-rw-r--r--gcc/loop-doloop.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 39e6ca92734..8dcfea5bba8 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -410,6 +410,7 @@ doloop_modify (struct loop *loop, struct niter_desc *desc,
basic_block loop_end = desc->out_edge->src;
enum machine_mode mode;
rtx true_prob_val;
+ double_int iterations;
jump_insn = BB_END (loop_end);
@@ -460,9 +461,10 @@ doloop_modify (struct loop *loop, struct niter_desc *desc,
/* Determine if the iteration counter will be non-negative.
Note that the maximum value loaded is iterations_max - 1. */
- if (desc->niter_max
- <= ((unsigned HOST_WIDEST_INT) 1
- << (GET_MODE_PRECISION (mode) - 1)))
+ if (max_loop_iterations (loop, &iterations)
+ && (iterations.ule (double_int_one.llshift
+ (GET_MODE_PRECISION (mode) - 1,
+ GET_MODE_PRECISION (mode)))))
nonneg = 1;
break;
@@ -548,9 +550,17 @@ doloop_modify (struct loop *loop, struct niter_desc *desc,
{
rtx init;
unsigned level = get_loop_level (loop) + 1;
+ double_int iter;
+ rtx iter_rtx;
+
+ if (!max_loop_iterations (loop, &iter)
+ || !iter.fits_shwi ())
+ iter_rtx = const0_rtx;
+ else
+ iter_rtx = GEN_INT (iter.to_shwi());
init = gen_doloop_begin (counter_reg,
desc->const_iter ? desc->niter_expr : const0_rtx,
- GEN_INT (desc->niter_max),
+ iter_rtx,
GEN_INT (level));
if (init)
{
@@ -608,6 +618,7 @@ doloop_optimize (struct loop *loop)
struct niter_desc *desc;
unsigned word_mode_size;
unsigned HOST_WIDE_INT word_mode_max;
+ double_int iter;
if (dump_file)
fprintf (dump_file, "Doloop: Processing loop %d.\n", loop->num);
@@ -658,7 +669,11 @@ doloop_optimize (struct loop *loop)
count = copy_rtx (desc->niter_expr);
iterations = desc->const_iter ? desc->niter_expr : const0_rtx;
- iterations_max = GEN_INT (desc->niter_max);
+ if (!max_loop_iterations (loop, &iter)
+ || !iter.fits_shwi ())
+ iterations_max = const0_rtx;
+ else
+ iterations_max = GEN_INT (iter.to_shwi());
level = get_loop_level (loop) + 1;
/* Generate looping insn. If the pattern FAILs then give up trying
@@ -678,7 +693,7 @@ doloop_optimize (struct loop *loop)
computed, we must be sure that the number of iterations fits into
the new mode. */
&& (word_mode_size >= GET_MODE_PRECISION (mode)
- || desc->niter_max <= word_mode_max))
+ || iter.ule (double_int::from_shwi (word_mode_max))))
{
if (word_mode_size > GET_MODE_PRECISION (mode))
{