aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 8f1e2b4..84ae610 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -91,7 +91,7 @@ split_to_var_and_offset (tree expr, tree *var, mpz_t offset)
*var = op0;
/* Always sign extend the offset. */
off = tree_to_double_int (op1);
- off = double_int_sext (off, TYPE_PRECISION (type));
+ off = off.sext (TYPE_PRECISION (type));
mpz_set_double_int (offset, off, false);
if (negate)
mpz_neg (offset, offset);
@@ -170,7 +170,7 @@ bound_difference_of_offsetted_base (tree type, mpz_t x, mpz_t y,
}
mpz_init (m);
- mpz_set_double_int (m, double_int_mask (TYPE_PRECISION (type)), true);
+ mpz_set_double_int (m, double_int::mask (TYPE_PRECISION (type)), true);
mpz_add_ui (m, m, 1);
mpz_sub (bnds->up, x, y);
mpz_set (bnds->below, bnds->up);
@@ -457,7 +457,7 @@ bounds_add (bounds *bnds, double_int delta, tree type)
mpz_set_double_int (mdelta, delta, false);
mpz_init (max);
- mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type)), true);
+ mpz_set_double_int (max, double_int::mask (TYPE_PRECISION (type)), true);
mpz_add (bnds->up, bnds->up, mdelta);
mpz_add (bnds->below, bnds->below, mdelta);
@@ -573,7 +573,7 @@ number_of_iterations_ne_max (mpz_t bnd, bool no_overflow, tree c, tree s,
the whole # of iterations analysis will fail). */
if (!no_overflow)
{
- max = double_int_mask (TYPE_PRECISION (TREE_TYPE (c))
+ max = double_int::mask (TYPE_PRECISION (TREE_TYPE (c))
- tree_low_cst (num_ending_zeros (s), 1));
mpz_set_double_int (bnd, max, true);
return;
@@ -581,7 +581,7 @@ number_of_iterations_ne_max (mpz_t bnd, bool no_overflow, tree c, tree s,
/* Now we know that the induction variable does not overflow, so the loop
iterates at most (range of type / S) times. */
- mpz_set_double_int (bnd, double_int_mask (TYPE_PRECISION (TREE_TYPE (c))),
+ mpz_set_double_int (bnd, double_int::mask (TYPE_PRECISION (TREE_TYPE (c))),
true);
/* If the induction variable is guaranteed to reach the value of C before
@@ -922,9 +922,8 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1,
dstep = tree_to_double_int (iv0->step);
else
{
- dstep = double_int_sext (tree_to_double_int (iv1->step),
- TYPE_PRECISION (type));
- dstep = double_int_neg (dstep);
+ dstep = tree_to_double_int (iv1->step).sext (TYPE_PRECISION (type));
+ dstep = -dstep;
}
mpz_init (mstep);
@@ -935,7 +934,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1,
rolls_p = mpz_cmp (mstep, bnds->below) <= 0;
mpz_init (max);
- mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type)), true);
+ mpz_set_double_int (max, double_int::mask (TYPE_PRECISION (type)), true);
mpz_add (max, max, mstep);
no_overflow_p = (mpz_cmp (bnds->up, max) <= 0
/* For pointers, only values lying inside a single object
@@ -2394,7 +2393,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
/* If the bound does not fit in TYPE, max. value of TYPE could be
attained. */
- if (double_int_ucmp (max, bnd) < 0)
+ if (max.ult (bnd))
return max;
return bnd;
@@ -2410,27 +2409,27 @@ derive_constant_upper_bound_ops (tree type, tree op0,
choose the most logical way how to treat this constant regardless
of the signedness of the type. */
cst = tree_to_double_int (op1);
- cst = double_int_sext (cst, TYPE_PRECISION (type));
+ cst = cst.sext (TYPE_PRECISION (type));
if (code != MINUS_EXPR)
- cst = double_int_neg (cst);
+ cst = -cst;
bnd = derive_constant_upper_bound (op0);
- if (double_int_negative_p (cst))
+ if (cst.is_negative ())
{
- cst = double_int_neg (cst);
+ cst = -cst;
/* Avoid CST == 0x80000... */
- if (double_int_negative_p (cst))
+ if (cst.is_negative ())
return max;;
/* OP0 + CST. We need to check that
BND <= MAX (type) - CST. */
- mmax = double_int_sub (max, cst);
- if (double_int_ucmp (bnd, mmax) > 0)
+ mmax -= cst;
+ if (bnd.ugt (mmax))
return max;
- return double_int_add (bnd, cst);
+ return bnd + cst;
}
else
{
@@ -2447,7 +2446,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
/* This should only happen if the type is unsigned; however, for
buggy programs that use overflowing signed arithmetics even with
-fno-wrapv, this condition may also be true for signed values. */
- if (double_int_ucmp (bnd, cst) < 0)
+ if (bnd.ult (cst))
return max;
if (TYPE_UNSIGNED (type))
@@ -2458,7 +2457,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
return max;
}
- bnd = double_int_sub (bnd, cst);
+ bnd -= cst;
}
return bnd;
@@ -2470,7 +2469,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
return max;
bnd = derive_constant_upper_bound (op0);
- return double_int_udiv (bnd, tree_to_double_int (op1), FLOOR_DIV_EXPR);
+ return bnd.udiv (tree_to_double_int (op1), FLOOR_DIV_EXPR);
case BIT_AND_EXPR:
if (TREE_CODE (op1) != INTEGER_CST
@@ -2503,14 +2502,14 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic,
current estimation is smaller. */
if (upper
&& (!loop->any_upper_bound
- || double_int_ucmp (i_bound, loop->nb_iterations_upper_bound) < 0))
+ || 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
- || double_int_ucmp (i_bound, loop->nb_iterations_estimate) < 0))
+ || i_bound.ult (loop->nb_iterations_estimate)))
{
loop->any_estimate = true;
loop->nb_iterations_estimate = i_bound;
@@ -2520,8 +2519,7 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic,
number of iterations, use the upper bound instead. */
if (loop->any_upper_bound
&& loop->any_estimate
- && double_int_ucmp (loop->nb_iterations_upper_bound,
- loop->nb_iterations_estimate) < 0)
+ && loop->nb_iterations_upper_bound.ult (loop->nb_iterations_estimate))
loop->nb_iterations_estimate = loop->nb_iterations_upper_bound;
}
@@ -2583,10 +2581,10 @@ record_estimate (struct loop *loop, tree bound, double_int i_bound,
delta = double_int_zero;
else
delta = double_int_one;
- i_bound = double_int_add (i_bound, delta);
+ i_bound += delta;
/* If an overflow occurred, ignore the result. */
- if (double_int_ucmp (i_bound, delta) < 0)
+ if (i_bound.ult (delta))
return;
record_niter_bound (loop, i_bound, realistic, upper);
@@ -3050,9 +3048,9 @@ estimated_loop_iterations_int (struct loop *loop)
if (!estimated_loop_iterations (loop, &nit))
return -1;
- if (!double_int_fits_in_shwi_p (nit))
+ if (!nit.fits_shwi ())
return -1;
- hwi_nit = double_int_to_shwi (nit);
+ hwi_nit = nit.to_shwi ();
return hwi_nit < 0 ? -1 : hwi_nit;
}
@@ -3070,9 +3068,9 @@ max_loop_iterations_int (struct loop *loop)
if (!max_loop_iterations (loop, &nit))
return -1;
- if (!double_int_fits_in_shwi_p (nit))
+ if (!nit.fits_shwi ())
return -1;
- hwi_nit = double_int_to_shwi (nit);
+ hwi_nit = nit.to_shwi ();
return hwi_nit < 0 ? -1 : hwi_nit;
}
@@ -3129,9 +3127,9 @@ max_stmt_executions (struct loop *loop, double_int *nit)
nit_minus_one = *nit;
- *nit = double_int_add (*nit, double_int_one);
+ *nit += double_int_one;
- return double_int_ucmp (*nit, nit_minus_one) > 0;
+ return (*nit).ugt (nit_minus_one);
}
/* Sets NIT to the estimated number of executions of the latch of the
@@ -3148,9 +3146,9 @@ estimated_stmt_executions (struct loop *loop, double_int *nit)
nit_minus_one = *nit;
- *nit = double_int_add (*nit, double_int_one);
+ *nit += double_int_one;
- return double_int_ucmp (*nit, nit_minus_one) > 0;
+ return (*nit).ugt (nit_minus_one);
}
/* Records estimates on numbers of iterations of loops. */
@@ -3255,8 +3253,8 @@ n_of_executions_at_most (gimple stmt,
|| (gimple_bb (stmt) != gimple_bb (niter_bound->stmt)
&& !stmt_dominates_stmt_p (niter_bound->stmt, stmt)))
{
- bound = double_int_add (bound, double_int_one);
- if (double_int_zero_p (bound)
+ bound += double_int_one;
+ if (bound.is_zero ()
|| !double_int_fits_to_tree_p (nit_type, bound))
return false;
}