summaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorLawrence Crowl <crowl@google.com>2012-09-07 00:06:35 +0000
committerLawrence Crowl <crowl@gcc.gnu.org>2012-09-07 00:06:35 +0000
commit27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7 (patch)
tree82231821d6793cd33f15d6b9792a8b82f2ec15d1 /gcc/tree-vrp.c
parent316b938ed79ef024177ab82057a061a7a4b5af67 (diff)
downloadgcc-27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7.tar.gz
Modify gcc/*.[hc] double_int call sites to use the new interface.
This change entailed adding a few new methods to double_int. The change results in a 0.163% time improvement with a 70% confidence. Tested on x86_64. Index: gcc/ChangeLog 2012-09-06 Lawrence Crowl <crowl@google.com> * double-int.h (double_int::operator &=): New. (double_int::operator ^=): New. (double_int::operator |=): New. (double_int::mul_with_sign): Modify overflow parameter to bool*. (double_int::add_with_sign): New. (double_int::ule): New. (double_int::sle): New. (binary double_int::operator *): Remove parameter name. (binary double_int::operator +): Likewise. (binary double_int::operator -): Likewise. (binary double_int::operator &): Likewise. (double_int::operator |): Likewise. (double_int::operator ^): Likewise. (double_int::and_not): Likewise. (double_int::from_shwi): Tidy formatting. (double_int::from_uhwi): Likewise. (double_int::from_uhwi): Likewise. * double-int.c (double_int::mul_with_sign): Modify overflow parameter to bool*. (double_int::add_with_sign): New. (double_int::ule): New. (double_int::sle): New. * builtins.c: Modify to use the new double_int interface. * cgraph.c: Likewise. * combine.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * gimple-fold.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimplify-rtx.c: Likewise. * ipa-prop.c: Likewise. * loop-iv.c: Likewise. * optabs.c: Likewise. * stor-layout.c: Likewise. * tree-affine.c: Likewise. * tree-cfg.c: Likewise. * tree-dfa.c: Likewise. * tree-flow-inline.h: Likewise. * tree-object-size.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-sccvn: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vrp.c: Likewise. * tree.h: Likewise. * tree.c: Likewise. * varasm.c: Likewise. From-SVN: r191047
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c390
1 files changed, 175 insertions, 215 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 067b60f168f..9309264092a 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1961,9 +1961,9 @@ zero_nonzero_bits_from_vr (value_range_t *vr,
{
double_int dmin = tree_to_double_int (vr->min);
double_int dmax = tree_to_double_int (vr->max);
- double_int xor_mask = double_int_xor (dmin, dmax);
- *may_be_nonzero = double_int_ior (dmin, dmax);
- *must_be_nonzero = double_int_and (dmin, dmax);
+ double_int xor_mask = dmin ^ dmax;
+ *may_be_nonzero = dmin | dmax;
+ *must_be_nonzero = dmin & dmax;
if (xor_mask.high != 0)
{
unsigned HOST_WIDE_INT mask
@@ -2014,16 +2014,14 @@ ranges_from_anti_range (value_range_t *ar,
vr0->min = vrp_val_min (type);
vr0->max
= double_int_to_tree (type,
- double_int_sub (tree_to_double_int (ar->min),
- double_int_one));
+ tree_to_double_int (ar->min) - double_int_one);
}
if (!vrp_val_is_max (ar->max))
{
vr1->type = VR_RANGE;
vr1->min
= double_int_to_tree (type,
- double_int_add (tree_to_double_int (ar->max),
- double_int_one));
+ tree_to_double_int (ar->max) + double_int_one);
vr1->max = vrp_val_max (type);
}
if (vr0->type == VR_UNDEFINED)
@@ -2193,9 +2191,9 @@ static int
quad_int_cmp (double_int l0, double_int h0,
double_int l1, double_int h1, bool uns)
{
- int c = double_int_cmp (h0, h1, uns);
+ int c = h0.cmp (h1, uns);
if (c != 0) return c;
- return double_int_ucmp (l0, l1);
+ return l0.ucmp (l1);
}
static void
@@ -2389,37 +2387,33 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
double_int max1 = tree_to_double_int (vr1.max);
bool uns = TYPE_UNSIGNED (expr_type);
double_int type_min
- = double_int_min_value (TYPE_PRECISION (expr_type), uns);
+ = double_int::min_value (TYPE_PRECISION (expr_type), uns);
double_int type_max
- = double_int_max_value (TYPE_PRECISION (expr_type), uns);
+ = double_int::max_value (TYPE_PRECISION (expr_type), uns);
double_int dmin, dmax;
int min_ovf = 0;
int max_ovf = 0;
if (code == PLUS_EXPR)
{
- dmin = double_int_add (min0, min1);
- dmax = double_int_add (max0, max1);
+ dmin = min0 + min1;
+ dmax = max0 + max1;
/* Check for overflow in double_int. */
- if (double_int_cmp (min1, double_int_zero, uns)
- != double_int_cmp (dmin, min0, uns))
- min_ovf = double_int_cmp (min0, dmin, uns);
- if (double_int_cmp (max1, double_int_zero, uns)
- != double_int_cmp (dmax, max0, uns))
- max_ovf = double_int_cmp (max0, dmax, uns);
+ if (min1.cmp (double_int_zero, uns) != dmin.cmp (min0, uns))
+ min_ovf = min0.cmp (dmin, uns);
+ if (max1.cmp (double_int_zero, uns) != dmax.cmp (max0, uns))
+ max_ovf = max0.cmp (dmax, uns);
}
else /* if (code == MINUS_EXPR) */
{
- dmin = double_int_sub (min0, max1);
- dmax = double_int_sub (max0, min1);
-
- if (double_int_cmp (double_int_zero, max1, uns)
- != double_int_cmp (dmin, min0, uns))
- min_ovf = double_int_cmp (min0, max1, uns);
- if (double_int_cmp (double_int_zero, min1, uns)
- != double_int_cmp (dmax, max0, uns))
- max_ovf = double_int_cmp (max0, min1, uns);
+ dmin = min0 - max1;
+ dmax = max0 - min1;
+
+ if (double_int_zero.cmp (max1, uns) != dmin.cmp (min0, uns))
+ min_ovf = min0.cmp (max1, uns);
+ if (double_int_zero.cmp (min1, uns) != dmax.cmp (max0, uns))
+ max_ovf = max0.cmp (min1, uns);
}
/* For non-wrapping arithmetic look at possibly smaller
@@ -2435,16 +2429,16 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
/* Check for type overflow. */
if (min_ovf == 0)
{
- if (double_int_cmp (dmin, type_min, uns) == -1)
+ if (dmin.cmp (type_min, uns) == -1)
min_ovf = -1;
- else if (double_int_cmp (dmin, type_max, uns) == 1)
+ else if (dmin.cmp (type_max, uns) == 1)
min_ovf = 1;
}
if (max_ovf == 0)
{
- if (double_int_cmp (dmax, type_min, uns) == -1)
+ if (dmax.cmp (type_min, uns) == -1)
max_ovf = -1;
- else if (double_int_cmp (dmax, type_max, uns) == 1)
+ else if (dmax.cmp (type_max, uns) == 1)
max_ovf = 1;
}
@@ -2453,9 +2447,9 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
/* If overflow wraps, truncate the values and adjust the
range kind and bounds appropriately. */
double_int tmin
- = double_int_ext (dmin, TYPE_PRECISION (expr_type), uns);
+ = dmin.ext (TYPE_PRECISION (expr_type), uns);
double_int tmax
- = double_int_ext (dmax, TYPE_PRECISION (expr_type), uns);
+ = dmax.ext (TYPE_PRECISION (expr_type), uns);
if (min_ovf == max_ovf)
{
/* No overflow or both overflow or underflow. The
@@ -2479,16 +2473,16 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
gcc_assert ((min_ovf == -1 && max_ovf == 0)
|| (max_ovf == 1 && min_ovf == 0));
type = VR_ANTI_RANGE;
- tmin = double_int_add (tmax, double_int_one);
- if (double_int_cmp (tmin, tmax, uns) < 0)
+ tmin = tmax + double_int_one;
+ if (tmin.cmp (tmax, uns) < 0)
covers = true;
- tmax = double_int_add (tem, double_int_minus_one);
+ tmax = tem + double_int_minus_one;
if (double_int_cmp (tmax, tem, uns) > 0)
covers = true;
/* If the anti-range would cover nothing, drop to varying.
Likewise if the anti-range bounds are outside of the
types values. */
- if (covers || double_int_cmp (tmin, tmax, uns) > 0)
+ if (covers || tmin.cmp (tmax, uns) > 0)
{
set_value_range_to_varying (vr);
return;
@@ -2605,8 +2599,8 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
prod2l, prod2h, prod3l, prod3h;
bool uns0, uns1, uns;
- sizem1 = double_int_max_value (TYPE_PRECISION (expr_type), true);
- size = double_int_add (sizem1, double_int_one);
+ sizem1 = double_int::max_value (TYPE_PRECISION (expr_type), true);
+ size = sizem1 + double_int_one;
min0 = tree_to_double_int (vr0.min);
max0 = tree_to_double_int (vr0.max);
@@ -2619,19 +2613,19 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
/* Canonicalize the intervals. */
if (TYPE_UNSIGNED (expr_type))
{
- double_int min2 = double_int_sub (size, min0);
- if (double_int_cmp (min2, max0, true) < 0)
+ double_int min2 = size - min0;
+ if (min2.cmp (max0, true) < 0)
{
- min0 = double_int_neg (min2);
- max0 = double_int_sub (max0, size);
+ min0 = -min2;
+ max0 -= size;
uns0 = false;
}
- min2 = double_int_sub (size, min1);
- if (double_int_cmp (min2, max1, true) < 0)
+ min2 = size - min1;
+ if (min2.cmp (max1, true) < 0)
{
- min1 = double_int_neg (min2);
- max1 = double_int_sub (max1, size);
+ min1 = -min2;
+ max1 -= size;
uns1 = false;
}
}
@@ -2641,37 +2635,37 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
min1.low, min1.high,
&prod0l.low, &prod0l.high,
&prod0h.low, &prod0h.high, true);
- if (!uns0 && double_int_negative_p (min0))
- prod0h = double_int_sub (prod0h, min1);
- if (!uns1 && double_int_negative_p (min1))
- prod0h = double_int_sub (prod0h, min0);
+ if (!uns0 && min0.is_negative ())
+ prod0h -= min1;
+ if (!uns1 && min1.is_negative ())
+ prod0h -= min0;
mul_double_wide_with_sign (min0.low, min0.high,
max1.low, max1.high,
&prod1l.low, &prod1l.high,
&prod1h.low, &prod1h.high, true);
- if (!uns0 && double_int_negative_p (min0))
- prod1h = double_int_sub (prod1h, max1);
- if (!uns1 && double_int_negative_p (max1))
- prod1h = double_int_sub (prod1h, min0);
+ if (!uns0 && min0.is_negative ())
+ prod1h -= max1;
+ if (!uns1 && max1.is_negative ())
+ prod1h -= min0;
mul_double_wide_with_sign (max0.low, max0.high,
min1.low, min1.high,
&prod2l.low, &prod2l.high,
&prod2h.low, &prod2h.high, true);
- if (!uns0 && double_int_negative_p (max0))
- prod2h = double_int_sub (prod2h, min1);
- if (!uns1 && double_int_negative_p (min1))
- prod2h = double_int_sub (prod2h, max0);
+ if (!uns0 && max0.is_negative ())
+ prod2h -= min1;
+ if (!uns1 && min1.is_negative ())
+ prod2h -= max0;
mul_double_wide_with_sign (max0.low, max0.high,
max1.low, max1.high,
&prod3l.low, &prod3l.high,
&prod3h.low, &prod3h.high, true);
- if (!uns0 && double_int_negative_p (max0))
- prod3h = double_int_sub (prod3h, max1);
- if (!uns1 && double_int_negative_p (max1))
- prod3h = double_int_sub (prod3h, max0);
+ if (!uns0 && max0.is_negative ())
+ prod3h -= max1;
+ if (!uns1 && max1.is_negative ())
+ prod3h -= max0;
/* Sort the 4 products. */
quad_int_pair_sort (&prod0l, &prod0h, &prod3l, &prod3h, uns);
@@ -2680,23 +2674,23 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
quad_int_pair_sort (&prod2l, &prod2h, &prod3l, &prod3h, uns);
/* Max - min. */
- if (double_int_zero_p (prod0l))
+ if (prod0l.is_zero ())
{
prod1l = double_int_zero;
- prod1h = double_int_neg (prod0h);
+ prod1h = -prod0h;
}
else
{
- prod1l = double_int_neg (prod0l);
- prod1h = double_int_not (prod0h);
+ prod1l = -prod0l;
+ prod1h = ~prod0h;
}
- prod2l = double_int_add (prod3l, prod1l);
- prod2h = double_int_add (prod3h, prod1h);
- if (double_int_ucmp (prod2l, prod3l) < 0)
- prod2h = double_int_add (prod2h, double_int_one); /* carry */
+ prod2l = prod3l + prod1l;
+ prod2h = prod3h + prod1h;
+ if (prod2l.ult (prod3l))
+ prod2h += double_int_one; /* carry */
- if (!double_int_zero_p (prod2h)
- || double_int_cmp (prod2l, sizem1, true) >= 0)
+ if (!prod2h.is_zero ()
+ || prod2l.cmp (sizem1, true) >= 0)
{
/* the range covers all values. */
set_value_range_to_varying (vr);
@@ -2755,11 +2749,9 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
vr1p.type = VR_RANGE;
vr1p.min
= double_int_to_tree (expr_type,
- double_int_lshift
- (double_int_one,
- TREE_INT_CST_LOW (vr1.min),
- TYPE_PRECISION (expr_type),
- false));
+ double_int_one
+ .llshift (TREE_INT_CST_LOW (vr1.min),
+ TYPE_PRECISION (expr_type)));
vr1p.max = vr1p.min;
/* We have to use a wrapping multiply though as signed overflow
on lshifts is implementation defined in C89. */
@@ -2903,9 +2895,8 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
{
double_int dmax;
min = double_int_to_tree (expr_type,
- double_int_and (must_be_nonzero0,
- must_be_nonzero1));
- dmax = double_int_and (may_be_nonzero0, may_be_nonzero1);
+ must_be_nonzero0 & must_be_nonzero1);
+ dmax = may_be_nonzero0 & may_be_nonzero1;
/* If both input ranges contain only negative values we can
truncate the result range maximum to the minimum of the
input range maxima. */
@@ -2913,19 +2904,19 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
&& tree_int_cst_sgn (vr0.max) < 0
&& tree_int_cst_sgn (vr1.max) < 0)
{
- dmax = double_int_min (dmax, tree_to_double_int (vr0.max),
+ dmax = dmax.min (tree_to_double_int (vr0.max),
TYPE_UNSIGNED (expr_type));
- dmax = double_int_min (dmax, tree_to_double_int (vr1.max),
+ dmax = dmax.min (tree_to_double_int (vr1.max),
TYPE_UNSIGNED (expr_type));
}
/* If either input range contains only non-negative values
we can truncate the result range maximum to the respective
maximum of the input range. */
if (int_cst_range0 && tree_int_cst_sgn (vr0.min) >= 0)
- dmax = double_int_min (dmax, tree_to_double_int (vr0.max),
+ dmax = dmax.min (tree_to_double_int (vr0.max),
TYPE_UNSIGNED (expr_type));
if (int_cst_range1 && tree_int_cst_sgn (vr1.min) >= 0)
- dmax = double_int_min (dmax, tree_to_double_int (vr1.max),
+ dmax = dmax.min (tree_to_double_int (vr1.max),
TYPE_UNSIGNED (expr_type));
max = double_int_to_tree (expr_type, dmax);
}
@@ -2933,9 +2924,8 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
{
double_int dmin;
max = double_int_to_tree (expr_type,
- double_int_ior (may_be_nonzero0,
- may_be_nonzero1));
- dmin = double_int_ior (must_be_nonzero0, must_be_nonzero1);
+ may_be_nonzero0 | may_be_nonzero1);
+ dmin = must_be_nonzero0 | must_be_nonzero1;
/* If the input ranges contain only positive values we can
truncate the minimum of the result range to the maximum
of the input range minima. */
@@ -2943,40 +2933,30 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
&& tree_int_cst_sgn (vr0.min) >= 0
&& tree_int_cst_sgn (vr1.min) >= 0)
{
- dmin = double_int_max (dmin, tree_to_double_int (vr0.min),
- TYPE_UNSIGNED (expr_type));
- dmin = double_int_max (dmin, tree_to_double_int (vr1.min),
- TYPE_UNSIGNED (expr_type));
+ dmin = dmin.max (tree_to_double_int (vr0.min),
+ TYPE_UNSIGNED (expr_type));
+ dmin = dmin.max (tree_to_double_int (vr1.min),
+ TYPE_UNSIGNED (expr_type));
}
/* If either input range contains only negative values
we can truncate the minimum of the result range to the
respective minimum range. */
if (int_cst_range0 && tree_int_cst_sgn (vr0.max) < 0)
- dmin = double_int_max (dmin, tree_to_double_int (vr0.min),
- TYPE_UNSIGNED (expr_type));
+ dmin = dmin.max (tree_to_double_int (vr0.min),
+ TYPE_UNSIGNED (expr_type));
if (int_cst_range1 && tree_int_cst_sgn (vr1.max) < 0)
- dmin = double_int_max (dmin, tree_to_double_int (vr1.min),
- TYPE_UNSIGNED (expr_type));
+ dmin = dmin.max (tree_to_double_int (vr1.min),
+ TYPE_UNSIGNED (expr_type));
min = double_int_to_tree (expr_type, dmin);
}
else if (code == BIT_XOR_EXPR)
{
double_int result_zero_bits, result_one_bits;
- result_zero_bits
- = double_int_ior (double_int_and (must_be_nonzero0,
- must_be_nonzero1),
- double_int_not
- (double_int_ior (may_be_nonzero0,
- may_be_nonzero1)));
- result_one_bits
- = double_int_ior (double_int_and
- (must_be_nonzero0,
- double_int_not (may_be_nonzero1)),
- double_int_and
- (must_be_nonzero1,
- double_int_not (may_be_nonzero0)));
- max = double_int_to_tree (expr_type,
- double_int_not (result_zero_bits));
+ result_zero_bits = (must_be_nonzero0 & must_be_nonzero1)
+ | ~(may_be_nonzero0 | may_be_nonzero1);
+ result_one_bits = must_be_nonzero0.and_not (may_be_nonzero1)
+ | must_be_nonzero1.and_not (may_be_nonzero0);
+ max = double_int_to_tree (expr_type, ~result_zero_bits);
min = double_int_to_tree (expr_type, result_one_bits);
/* If the range has all positive or all negative values the
result is better than VARYING. */
@@ -3606,10 +3586,10 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop,
value_range_t maxvr = VR_INITIALIZER;
double_int dtmp;
bool unsigned_p = TYPE_UNSIGNED (TREE_TYPE (step));
- int overflow = 0;
+ bool overflow = false;
- dtmp = double_int_mul_with_sign (tree_to_double_int (step), nit,
- unsigned_p, &overflow);
+ dtmp = tree_to_double_int (step)
+ .mul_with_sign (nit, unsigned_p, &overflow);
/* If the multiplication overflowed we can't do a meaningful
adjustment. Likewise if the result doesn't fit in the type
of the induction variable. For a signed type we have to
@@ -4519,19 +4499,19 @@ masked_increment (double_int val, double_int mask, double_int sgnbit,
double_int bit = double_int_one, res;
unsigned int i;
- val = double_int_xor (val, sgnbit);
- for (i = 0; i < prec; i++, bit = double_int_add (bit, bit))
+ val ^= sgnbit;
+ for (i = 0; i < prec; i++, bit += bit)
{
res = mask;
- if (double_int_zero_p (double_int_and (res, bit)))
+ if ((res & bit).is_zero ())
continue;
- res = double_int_sub (bit, double_int_one);
- res = double_int_and_not (double_int_add (val, bit), res);
- res = double_int_and (res, mask);
- if (double_int_ucmp (res, val) > 0)
- return double_int_xor (res, sgnbit);
+ res = bit - double_int_one;
+ res = (val + bit).and_not (res);
+ res &= mask;
+ if (res.ugt (val))
+ return res ^ sgnbit;
}
- return double_int_xor (val, sgnbit);
+ return val ^ sgnbit;
}
/* Try to register an edge assertion for SSA name NAME on edge E for
@@ -4735,7 +4715,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
&& live_on_edge (e, name2)
&& !has_single_use (name2))
{
- mask = double_int_mask (tree_low_cst (cst2, 1));
+ mask = double_int::mask (tree_low_cst (cst2, 1));
val2 = fold_binary (LSHIFT_EXPR, TREE_TYPE (val), val, cst2);
}
}
@@ -4766,9 +4746,9 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
else
{
double_int maxval
- = double_int_max_value (prec, TYPE_UNSIGNED (TREE_TYPE (val)));
- mask = double_int_ior (tree_to_double_int (val2), mask);
- if (double_int_equal_p (mask, maxval))
+ = double_int::max_value (prec, TYPE_UNSIGNED (TREE_TYPE (val)));
+ mask |= tree_to_double_int (val2);
+ if (mask == maxval)
new_val = NULL_TREE;
else
new_val = double_int_to_tree (TREE_TYPE (val2), mask);
@@ -4835,12 +4815,12 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
bool valid_p = false, valn = false, cst2n = false;
enum tree_code ccode = comp_code;
- valv = double_int_zext (tree_to_double_int (val), prec);
- cst2v = double_int_zext (tree_to_double_int (cst2), prec);
+ valv = tree_to_double_int (val).zext (prec);
+ cst2v = tree_to_double_int (cst2).zext (prec);
if (!TYPE_UNSIGNED (TREE_TYPE (val)))
{
- valn = double_int_negative_p (double_int_sext (valv, prec));
- cst2n = double_int_negative_p (double_int_sext (cst2v, prec));
+ valn = valv.sext (prec).is_negative ();
+ cst2n = cst2v.sext (prec).is_negative ();
}
/* If CST2 doesn't have most significant bit set,
but VAL is negative, we have comparison like
@@ -4848,12 +4828,10 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
if (!cst2n && valn)
ccode = ERROR_MARK;
if (cst2n)
- sgnbit = double_int_zext (double_int_lshift (double_int_one,
- prec - 1, prec,
- false), prec);
+ sgnbit = double_int_one.llshift (prec - 1, prec).zext (prec);
else
sgnbit = double_int_zero;
- minv = double_int_and (valv, cst2v);
+ minv = valv & cst2v;
switch (ccode)
{
case EQ_EXPR:
@@ -4861,15 +4839,15 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
(should be equal to VAL, otherwise we probably should
have folded the comparison into false) and
maximum unsigned value is VAL | ~CST2. */
- maxv = double_int_ior (valv, double_int_not (cst2v));
- maxv = double_int_zext (maxv, prec);
+ maxv = valv | ~cst2v;
+ maxv = maxv.zext (prec);
valid_p = true;
break;
case NE_EXPR:
- tem = double_int_ior (valv, double_int_not (cst2v));
- tem = double_int_zext (tem, prec);
+ tem = valv | ~cst2v;
+ tem = tem.zext (prec);
/* If VAL is 0, handle (X & CST2) != 0 as (X & CST2) > 0U. */
- if (double_int_zero_p (valv))
+ if (valv.is_zero ())
{
cst2n = false;
sgnbit = double_int_zero;
@@ -4877,7 +4855,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
}
/* If (VAL | ~CST2) is all ones, handle it as
(X & CST2) < VAL. */
- if (double_int_equal_p (tem, double_int_mask (prec)))
+ if (tem == double_int::mask (prec))
{
cst2n = false;
valn = false;
@@ -4885,19 +4863,17 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
goto lt_expr;
}
if (!cst2n
- && double_int_negative_p (double_int_sext (cst2v, prec)))
- sgnbit = double_int_zext (double_int_lshift (double_int_one,
- prec - 1, prec,
- false), prec);
- if (!double_int_zero_p (sgnbit))
+ && cst2v.sext (prec).is_negative ())
+ sgnbit = double_int_one.llshift (prec - 1, prec).zext (prec);
+ if (!sgnbit.is_zero ())
{
- if (double_int_equal_p (valv, sgnbit))
+ if (valv == sgnbit)
{
cst2n = true;
valn = true;
goto gt_expr;
}
- if (double_int_equal_p (tem, double_int_mask (prec - 1)))
+ if (tem == double_int::mask (prec - 1))
{
cst2n = true;
goto lt_expr;
@@ -4912,15 +4888,15 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
comparison, if CST2 doesn't have most significant bit
set, handle it similarly. If CST2 has MSB set,
the minimum is the same, and maximum is ~0U/2. */
- if (!double_int_equal_p (minv, valv))
+ if (minv != valv)
{
/* If (VAL & CST2) != VAL, X & CST2 can't be equal to
VAL. */
minv = masked_increment (valv, cst2v, sgnbit, prec);
- if (double_int_equal_p (minv, valv))
+ if (minv == valv)
break;
}
- maxv = double_int_mask (prec - (cst2n ? 1 : 0));
+ maxv = double_int::mask (prec - (cst2n ? 1 : 0));
valid_p = true;
break;
case GT_EXPR:
@@ -4929,9 +4905,9 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
&& (MINV & CST2) == MINV, if any. If VAL is signed and
CST2 has MSB set, compute it biased by 1 << (prec - 1). */
minv = masked_increment (valv, cst2v, sgnbit, prec);
- if (double_int_equal_p (minv, valv))
+ if (minv == valv)
break;
- maxv = double_int_mask (prec - (cst2n ? 1 : 0));
+ maxv = double_int::mask (prec - (cst2n ? 1 : 0));
valid_p = true;
break;
case LE_EXPR:
@@ -4943,17 +4919,17 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
For signed comparison, if CST2 doesn't have most
significant bit set, handle it similarly. If CST2 has
MSB set, the maximum is the same and minimum is INT_MIN. */
- if (double_int_equal_p (minv, valv))
+ if (minv == valv)
maxv = valv;
else
{
maxv = masked_increment (valv, cst2v, sgnbit, prec);
- if (double_int_equal_p (maxv, valv))
+ if (maxv == valv)
break;
- maxv = double_int_sub (maxv, double_int_one);
+ maxv -= double_int_one;
}
- maxv = double_int_ior (maxv, double_int_not (cst2v));
- maxv = double_int_zext (maxv, prec);
+ maxv |= ~cst2v;
+ maxv = maxv.zext (prec);
minv = sgnbit;
valid_p = true;
break;
@@ -4967,21 +4943,21 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
For signed comparison, if CST2 doesn't have most
significant bit set, handle it similarly. If CST2 has
MSB set, the maximum is the same and minimum is INT_MIN. */
- if (double_int_equal_p (minv, valv))
+ if (minv == valv)
{
- if (double_int_equal_p (valv, sgnbit))
+ if (valv == sgnbit)
break;
maxv = valv;
}
else
{
maxv = masked_increment (valv, cst2v, sgnbit, prec);
- if (double_int_equal_p (maxv, valv))
+ if (maxv == valv)
break;
}
- maxv = double_int_sub (maxv, double_int_one);
- maxv = double_int_ior (maxv, double_int_not (cst2v));
- maxv = double_int_zext (maxv, prec);
+ maxv -= double_int_one;
+ maxv |= ~cst2v;
+ maxv = maxv.zext (prec);
minv = sgnbit;
valid_p = true;
break;
@@ -4989,10 +4965,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
break;
}
if (valid_p
- && !double_int_equal_p (double_int_zext (double_int_sub (maxv,
- minv),
- prec),
- double_int_mask (prec)))
+ && (maxv - minv).zext (prec) != double_int::mask (prec))
{
tree tmp, new_val, type;
int i;
@@ -5008,12 +4981,11 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
type = build_nonstandard_integer_type (prec, 1);
tmp = build1 (NOP_EXPR, type, names[i]);
}
- if (!double_int_zero_p (minv))
+ if (!minv.is_zero ())
{
tmp = build2 (PLUS_EXPR, type, tmp,
- double_int_to_tree (type,
- double_int_neg (minv)));
- maxv2 = double_int_sub (maxv, minv);
+ double_int_to_tree (type, -minv));
+ maxv2 = maxv - minv;
}
new_val = double_int_to_tree (type, maxv2);
@@ -5947,20 +5919,16 @@ search_for_addr_array (tree t, location_t location)
return;
idx = mem_ref_offset (t);
- idx = double_int_sdiv (idx, tree_to_double_int (el_sz), TRUNC_DIV_EXPR);
- if (double_int_scmp (idx, double_int_zero) < 0)
+ idx = idx.sdiv (tree_to_double_int (el_sz), TRUNC_DIV_EXPR);
+ if (idx.slt (double_int_zero))
{
warning_at (location, OPT_Warray_bounds,
"array subscript is below array bounds");
TREE_NO_WARNING (t) = 1;
}
- else if (double_int_scmp (idx,
- double_int_add
- (double_int_add
- (tree_to_double_int (up_bound),
- double_int_neg
- (tree_to_double_int (low_bound))),
- double_int_one)) > 0)
+ else if (idx.sgt (tree_to_double_int (up_bound)
+ - tree_to_double_int (low_bound)
+ + double_int_one))
{
warning_at (location, OPT_Warray_bounds,
"array subscript is above array bounds");
@@ -8221,28 +8189,28 @@ simplify_bit_ops_using_ranges (gimple_stmt_iterator *gsi, gimple stmt)
switch (gimple_assign_rhs_code (stmt))
{
case BIT_AND_EXPR:
- mask = double_int_and_not (may_be_nonzero0, must_be_nonzero1);
- if (double_int_zero_p (mask))
+ mask = may_be_nonzero0.and_not (must_be_nonzero1);
+ if (mask.is_zero ())
{
op = op0;
break;
}
- mask = double_int_and_not (may_be_nonzero1, must_be_nonzero0);
- if (double_int_zero_p (mask))
+ mask = may_be_nonzero1.and_not (must_be_nonzero0);
+ if (mask.is_zero ())
{
op = op1;
break;
}
break;
case BIT_IOR_EXPR:
- mask = double_int_and_not (may_be_nonzero0, must_be_nonzero1);
- if (double_int_zero_p (mask))
+ mask = may_be_nonzero0.and_not (must_be_nonzero1);
+ if (mask.is_zero ())
{
op = op1;
break;
}
- mask = double_int_and_not (may_be_nonzero1, must_be_nonzero0);
- if (double_int_zero_p (mask))
+ mask = may_be_nonzero1.and_not (must_be_nonzero0);
+ if (mask.is_zero ())
{
op = op0;
break;
@@ -8549,42 +8517,34 @@ simplify_conversion_using_ranges (gimple stmt)
/* If the first conversion is not injective, the second must not
be widening. */
- if (double_int_cmp (double_int_sub (innermax, innermin),
- double_int_mask (middle_prec), true) > 0
+ if ((innermax - innermin).ugt (double_int::mask (middle_prec))
&& middle_prec < final_prec)
return false;
/* We also want a medium value so that we can track the effect that
narrowing conversions with sign change have. */
inner_unsigned_p = TYPE_UNSIGNED (TREE_TYPE (innerop));
if (inner_unsigned_p)
- innermed = double_int_rshift (double_int_mask (inner_prec),
- 1, inner_prec, false);
+ innermed = double_int::mask (inner_prec).lrshift (1, inner_prec);
else
innermed = double_int_zero;
- if (double_int_cmp (innermin, innermed, inner_unsigned_p) >= 0
- || double_int_cmp (innermed, innermax, inner_unsigned_p) >= 0)
+ if (innermin.cmp (innermed, inner_unsigned_p) >= 0
+ || innermed.cmp (innermax, inner_unsigned_p) >= 0)
innermed = innermin;
middle_unsigned_p = TYPE_UNSIGNED (TREE_TYPE (middleop));
- middlemin = double_int_ext (innermin, middle_prec, middle_unsigned_p);
- middlemed = double_int_ext (innermed, middle_prec, middle_unsigned_p);
- middlemax = double_int_ext (innermax, middle_prec, middle_unsigned_p);
+ middlemin = innermin.ext (middle_prec, middle_unsigned_p);
+ middlemed = innermed.ext (middle_prec, middle_unsigned_p);
+ middlemax = innermax.ext (middle_prec, middle_unsigned_p);
/* Require that the final conversion applied to both the original
and the intermediate range produces the same result. */
final_unsigned_p = TYPE_UNSIGNED (finaltype);
- if (!double_int_equal_p (double_int_ext (middlemin,
- final_prec, final_unsigned_p),
- double_int_ext (innermin,
- final_prec, final_unsigned_p))
- || !double_int_equal_p (double_int_ext (middlemed,
- final_prec, final_unsigned_p),
- double_int_ext (innermed,
- final_prec, final_unsigned_p))
- || !double_int_equal_p (double_int_ext (middlemax,
- final_prec, final_unsigned_p),
- double_int_ext (innermax,
- final_prec, final_unsigned_p)))
+ if (middlemin.ext (final_prec, final_unsigned_p)
+ != innermin.ext (final_prec, final_unsigned_p)
+ || middlemed.ext (final_prec, final_unsigned_p)
+ != innermed.ext (final_prec, final_unsigned_p)
+ || middlemax.ext (final_prec, final_unsigned_p)
+ != innermax.ext (final_prec, final_unsigned_p))
return false;
gimple_assign_set_rhs1 (stmt, innerop);
@@ -8629,11 +8589,11 @@ range_fits_type_p (value_range_t *vr, unsigned precision, bool unsigned_p)
/* Then we can perform the conversion on both ends and compare
the result for equality. */
- tem = double_int_ext (tree_to_double_int (vr->min), precision, unsigned_p);
- if (!double_int_equal_p (tree_to_double_int (vr->min), tem))
+ tem = tree_to_double_int (vr->min).ext (precision, unsigned_p);
+ if (tree_to_double_int (vr->min) != tem)
return false;
- tem = double_int_ext (tree_to_double_int (vr->max), precision, unsigned_p);
- if (!double_int_equal_p (tree_to_double_int (vr->max), tem))
+ tem = tree_to_double_int (vr->max).ext (precision, unsigned_p);
+ if (tree_to_double_int (vr->max) != tem)
return false;
return true;