summaryrefslogtreecommitdiff
path: root/gcc/loop-doloop.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-05 19:59:32 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-05 19:59:32 +0000
commita04a7bec5afd7a0c4d7f32d84f7fa4832600ce70 (patch)
tree514a08b4112a1fa404ac6c8db734121e060dd235 /gcc/loop-doloop.c
parentaeb682a27a580c32813c316b911b59b851f6f34e (diff)
downloadgcc-a04a7bec5afd7a0c4d7f32d84f7fa4832600ce70.tar.gz
Backport new doloop interface.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@204417 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-doloop.c')
-rw-r--r--gcc/loop-doloop.c70
1 files changed, 25 insertions, 45 deletions
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 9bbe448bef1..a2173dbd126 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -548,20 +548,8 @@ doloop_modify (struct loop *loop, struct niter_desc *desc,
#ifdef HAVE_doloop_begin
{
rtx init;
- unsigned level = get_loop_level (loop) + 1;
- widest_int iter;
- rtx iter_rtx;
-
- if (!get_max_loop_iterations (loop, &iter)
- || !wi::fits_shwi_p (iter))
- 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,
- iter_rtx,
- GEN_INT (level),
- doloop_seq);
+
+ init = gen_doloop_begin (counter_reg, doloop_seq);
if (init)
{
start_sequence ();
@@ -608,8 +596,8 @@ doloop_optimize (struct loop *loop)
{
enum machine_mode mode;
rtx doloop_seq, doloop_pat, doloop_reg;
- rtx iterations, count;
- rtx iterations_max;
+ rtx count;
+ widest_int iterations, iterations_max;
rtx start_label;
rtx condition;
unsigned level, est_niter;
@@ -617,7 +605,6 @@ doloop_optimize (struct loop *loop)
struct niter_desc *desc;
unsigned word_mode_size;
unsigned HOST_WIDE_INT word_mode_max;
- widest_int iter;
int entered_at_top;
if (dump_file)
@@ -667,25 +654,31 @@ doloop_optimize (struct loop *loop)
return false;
}
- count = copy_rtx (desc->niter_expr);
- iterations = desc->const_iter ? desc->niter_expr : const0_rtx;
- if (!get_max_loop_iterations (loop, &iter)
- || !wi::fits_shwi_p (iter))
- iterations_max = const0_rtx;
+ if (desc->const_iter)
+ iterations = widest_int::from (std::make_pair (desc->niter_expr, mode),
+ UNSIGNED);
else
- iterations_max = GEN_INT (iter.to_shwi ());
+ iterations = 0;
+ if (!get_max_loop_iterations (loop, &iterations_max))
+ iterations_max = 0;
level = get_loop_level (loop) + 1;
+ entered_at_top = (loop->latch == desc->in_edge->dest
+ && contains_no_active_insn_p (loop->latch));
+ if (!targetm.can_use_doloop_p (iterations, iterations_max, level,
+ entered_at_top))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Loop rejected by can_use_doloop_p.\n");
+ return false;
+ }
/* Generate looping insn. If the pattern FAILs then give up trying
to modify the loop since there is some aspect the back-end does
not like. */
+ count = copy_rtx (desc->niter_expr);
start_label = block_label (desc->in_edge->dest);
doloop_reg = gen_reg_rtx (mode);
- entered_at_top = (loop->latch == desc->in_edge->dest
- && contains_no_active_insn_p (loop->latch));
- doloop_seq = gen_doloop_end (doloop_reg, iterations, iterations_max,
- GEN_INT (level), start_label,
- GEN_INT (entered_at_top));
+ doloop_seq = gen_doloop_end (doloop_reg, start_label);
word_mode_size = GET_MODE_PRECISION (word_mode);
word_mode_max
@@ -696,27 +689,14 @@ 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)
- || wi::leu_p (iter, word_mode_max)))
+ || wi::leu_p (iterations_max, word_mode_max)))
{
if (word_mode_size > GET_MODE_PRECISION (mode))
- {
- count = simplify_gen_unary (ZERO_EXTEND, word_mode,
- count, mode);
- iterations = simplify_gen_unary (ZERO_EXTEND, word_mode,
- iterations, mode);
- iterations_max = simplify_gen_unary (ZERO_EXTEND, word_mode,
- iterations_max, mode);
- }
+ count = simplify_gen_unary (ZERO_EXTEND, word_mode, count, mode);
else
- {
- count = lowpart_subreg (word_mode, count, mode);
- iterations = lowpart_subreg (word_mode, iterations, mode);
- iterations_max = lowpart_subreg (word_mode, iterations_max, mode);
- }
+ count = lowpart_subreg (word_mode, count, mode);
PUT_MODE (doloop_reg, word_mode);
- doloop_seq = gen_doloop_end (doloop_reg, iterations, iterations_max,
- GEN_INT (level), start_label,
- GEN_INT (entered_at_top));
+ doloop_seq = gen_doloop_end (doloop_reg, start_label);
}
if (! doloop_seq)
{