// Default wide_int fold operation returns [MIN, MAX].
-value_range
-range_operator::wi_fold (tree type,
+void
+range_operator::wi_fold (value_range &r, tree type,
const wide_int &lh_lb ATTRIBUTE_UNUSED,
const wide_int &lh_ub ATTRIBUTE_UNUSED,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
const wide_int &rh_ub ATTRIBUTE_UNUSED) const
{
- return value_range (type);
+ r = value_range (type);
}
// The default for fold is to break all ranges into sub-ranges and
// invoke the wi_fold method on each sub-range pair.
-value_range
-range_operator::fold_range (tree type,
+void
+range_operator::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
+ value_range tmp;
for (unsigned x = 0; x < lh.num_pairs (); ++x)
for (unsigned y = 0; y < rh.num_pairs (); ++y)
{
wide_int lh_ub = lh.upper_bound (x);
wide_int rh_lb = rh.lower_bound (y);
wide_int rh_ub = rh.upper_bound (y);
- r.union_ (wi_fold (type, lh_lb, lh_ub, rh_lb, rh_ub));
+ wi_fold (tmp, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ r.union_ (tmp);
if (r.varying_p ())
- return r;
+ return;
}
- return r;
}
// The default for op1_range is to return false.
// Create and return a range from a pair of wide-ints that are known
// to have overflowed (or underflowed).
-static value_range
-value_range_from_overflowed_bounds (tree type,
+static void
+value_range_from_overflowed_bounds (value_range &r, tree type,
const wide_int &wmin,
const wide_int &wmax)
{
// Likewise if the anti-range bounds are outside of the types
// values.
if (covers || wi::cmp (tmin, tmax, sgn) > 0)
- return value_range (type);
-
- return value_range (VR_ANTI_RANGE, type, tmin, tmax);
+ r = value_range (type);
+ else
+ r = value_range (VR_ANTI_RANGE, type, tmin, tmax);
}
// Create and return a range from a pair of wide-ints. MIN_OVF and
// MAX_OVF describe any overflow that might have occurred while
// calculating WMIN and WMAX respectively.
-static value_range
-value_range_with_overflow (tree type,
+static void
+value_range_with_overflow (value_range &r, tree type,
const wide_int &wmin, const wide_int &wmax,
wi::overflow_type min_ovf = wi::OVF_NONE,
wi::overflow_type max_ovf = wi::OVF_NONE)
// For one bit precision if max != min, then the range covers all
// values.
if (prec == 1 && wi::ne_p (wmax, wmin))
- return value_range (type);
+ {
+ r = value_range (type);
+ return;
+ }
if (overflow_wraps)
{
// If the limits are swapped, we wrapped around and cover
// the entire range.
if (wi::gt_p (tmin, tmax, sgn))
- return value_range (type);
-
- // No overflow or both overflow or underflow. The range
- // kind stays normal.
- return value_range (type, tmin, tmax);
+ r = value_range (type);
+ else
+ // No overflow or both overflow or underflow. The range
+ // kind stays normal.
+ r = value_range (type, tmin, tmax);
+ return;
}
if ((min_ovf == wi::OVF_UNDERFLOW && max_ovf == wi::OVF_NONE)
|| (max_ovf == wi::OVF_OVERFLOW && min_ovf == wi::OVF_NONE))
- return value_range_from_overflowed_bounds (type, wmin, wmax);
-
- // Other underflow and/or overflow, drop to VR_VARYING.
- return value_range (type);
+ value_range_from_overflowed_bounds (r, type, wmin, wmax);
+ else
+ // Other underflow and/or overflow, drop to VR_VARYING.
+ r = value_range (type);
}
else
{
else
new_ub = wmax;
- return value_range (type, new_lb, new_ub);
+ r = value_range (type, new_lb, new_ub);
}
}
// the case where the bounds are swapped. In which case, we transform
// [10,5] into [MIN,5][10,MAX].
-static inline value_range
-create_possibly_reversed_range (tree type,
+static inline void
+create_possibly_reversed_range (value_range &r, tree type,
const wide_int &new_lb, const wide_int &new_ub)
{
signop s = TYPE_SIGN (type);
// If the bounds are swapped, treat the result as if an overflow occured.
if (wi::gt_p (new_lb, new_ub, s))
- return value_range_from_overflowed_bounds (type, new_lb, new_ub);
-
- // Otherwise its just a normal range.
- return value_range (type, new_lb, new_ub);
+ value_range_from_overflowed_bounds (r, type, new_lb, new_ub);
+ else
+ // Otherwise its just a normal range.
+ r = value_range (type, new_lb, new_ub);
}
// Return a value_range instance that is a boolean TRUE.
class operator_equal : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &val) const;
const value_range &val) const;
} op_equal;
-value_range
-operator_equal::fold_range (tree type,
+void
+operator_equal::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
// We can be sure the values are always equal or not if both ranges
// consist of a single value, and then compare them.
else
r = range_true_and_false (type);
}
-
- return r;
}
bool
class operator_not_equal : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_not_equal;
-value_range
-operator_not_equal::fold_range (tree type,
+void
+operator_not_equal::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
// We can be sure the values are always equal or not if both ranges
// consist of a single value, and then compare them.
else
r = range_true_and_false (type);
}
-
- return r;
}
bool
class operator_lt : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_lt;
-value_range
-operator_lt::fold_range (tree type,
+void
+operator_lt::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
signop sign = TYPE_SIGN (op1.type ());
gcc_checking_assert (sign == TYPE_SIGN (op2.type ()));
r = range_false (type);
else
r = range_true_and_false (type);
- return r;
}
bool
class operator_le : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_le;
-value_range
-operator_le::fold_range (tree type,
+void
+operator_le::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
signop sign = TYPE_SIGN (op1.type ());
gcc_checking_assert (sign == TYPE_SIGN (op2.type ()));
r = range_false (type);
else
r = range_true_and_false (type);
- return r;
}
bool
class operator_gt : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_gt;
-value_range
-operator_gt::fold_range (tree type,
+void
+operator_gt::fold_range (value_range &r, tree type,
const value_range &op1, const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
signop sign = TYPE_SIGN (op1.type ());
gcc_checking_assert (sign == TYPE_SIGN (op2.type ()));
r = range_false (type);
else
r = range_true_and_false (type);
- return r;
}
bool
class operator_ge : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_ge;
-value_range
-operator_ge::fold_range (tree type,
+void
+operator_ge::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (empty_range_check (r, op1, op2))
- return r;
+ return;
signop sign = TYPE_SIGN (op1.type ());
gcc_checking_assert (sign == TYPE_SIGN (op2.type ()));
r = range_false (type);
else
r = range_true_and_false (type);
- return r;
}
bool
virtual bool op2_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op1) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_plus;
-value_range
-operator_plus::wi_fold (tree type,
+void
+operator_plus::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
signop s = TYPE_SIGN (type);
wide_int new_lb = wi::add (lh_lb, rh_lb, s, &ov_lb);
wide_int new_ub = wi::add (lh_ub, rh_ub, s, &ov_ub);
- return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
+ value_range_with_overflow (r, type, new_lb, new_ub, ov_lb, ov_ub);
}
bool
const value_range &lhs,
const value_range &op2) const
{
- r = range_op_handler (MINUS_EXPR, type)->fold_range (type, lhs, op2);
+ range_op_handler (MINUS_EXPR, type)->fold_range (r, type, lhs, op2);
return true;
}
const value_range &lhs,
const value_range &op1) const
{
- r = range_op_handler (MINUS_EXPR, type)->fold_range (type, lhs, op1);
+ range_op_handler (MINUS_EXPR, type)->fold_range (r, type, lhs, op1);
return true;
}
virtual bool op2_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op1) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_minus;
-value_range
-operator_minus::wi_fold (tree type,
+void
+operator_minus::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
signop s = TYPE_SIGN (type);
wide_int new_lb = wi::sub (lh_lb, rh_ub, s, &ov_lb);
wide_int new_ub = wi::sub (lh_ub, rh_lb, s, &ov_ub);
- return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
+ value_range_with_overflow (r, type, new_lb, new_ub, ov_lb, ov_ub);
}
bool
const value_range &lhs,
const value_range &op2) const
{
- r = range_op_handler (PLUS_EXPR, type)->fold_range (type, lhs, op2);
+ range_op_handler (PLUS_EXPR, type)->fold_range (r, type, lhs, op2);
return true;
}
const value_range &lhs,
const value_range &op1) const
{
- r = fold_range (type, op1, lhs);
+ fold_range (r, type, op1, lhs);
return true;
}
class operator_min : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_min;
-value_range
-operator_min::wi_fold (tree type,
+void
+operator_min::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
signop s = TYPE_SIGN (type);
wide_int new_lb = wi::min (lh_lb, rh_lb, s);
wide_int new_ub = wi::min (lh_ub, rh_ub, s);
- return value_range_with_overflow (type, new_lb, new_ub);
+ value_range_with_overflow (r, type, new_lb, new_ub);
}
class operator_max : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_max;
-value_range
-operator_max::wi_fold (tree type,
+void
+operator_max::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
signop s = TYPE_SIGN (type);
wide_int new_lb = wi::max (lh_lb, rh_lb, s);
wide_int new_ub = wi::max (lh_ub, rh_ub, s);
- return value_range_with_overflow (type, new_lb, new_ub);
+ value_range_with_overflow (r, type, new_lb, new_ub);
}
const wide_int &) const = 0;
// Calculate the cross product of two sets of sub-ranges and return it.
- value_range wi_cross_product (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ void wi_cross_product (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
};
// Calculate the cross product of two sets of ranges and return it.
// MIN1, MIN0 OP MAX1, MAX0 OP MIN1 and MAX0 OP MAX0 OP MAX1) and then
// figure the smallest and largest values to form the new range.
-value_range
-cross_product_operator::wi_cross_product (tree type,
+void
+cross_product_operator::wi_cross_product (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
wide_int cp1, cp2, cp3, cp4;
+ // Default to varying.
+ r = value_range (type);
// Compute the 4 cross operations, bailing if we get an overflow we
// can't handle.
if (wi_op_overflows (cp1, type, lh_lb, rh_lb))
- return value_range (type);
+ return;
if (wi::eq_p (lh_lb, lh_ub))
cp3 = cp1;
else if (wi_op_overflows (cp3, type, lh_ub, rh_lb))
- return value_range (type);
+ return;
if (wi::eq_p (rh_lb, rh_ub))
cp2 = cp1;
else if (wi_op_overflows (cp2, type, lh_lb, rh_ub))
- return value_range (type);
+ return;
if (wi::eq_p (lh_lb, lh_ub))
cp4 = cp2;
else if (wi_op_overflows (cp4, type, lh_ub, rh_ub))
- return value_range (type);
+ return;
// Order pairs.
signop sign = TYPE_SIGN (type);
// Choose min and max from the ordered pairs.
wide_int res_lb = wi::min (cp1, cp3, sign);
wide_int res_ub = wi::max (cp2, cp4, sign);
- return value_range_with_overflow (type, res_lb, res_ub);
+ value_range_with_overflow (r, type, res_lb, res_ub);
}
class operator_mult : public cross_product_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res, tree type,
const wide_int &w0, const wide_int &w1) const;
} op_mult;
return overflow;
}
-value_range
-operator_mult::wi_fold (tree type,
+void
+operator_mult::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
if (TYPE_OVERFLOW_UNDEFINED (type))
- return wi_cross_product (type, lh_lb, lh_ub, rh_lb, rh_ub);
+ {
+ wi_cross_product (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ return;
+ }
// Multiply the ranges when overflow wraps. This is basically fancy
// code so we don't drop to varying with an unsigned
prod2 = prod3 - prod0;
if (wi::geu_p (prod2, sizem1))
// The range covers all values.
- return value_range (type);
-
- wide_int new_lb = wide_int::from (prod0, prec, sign);
- wide_int new_ub = wide_int::from (prod3, prec, sign);
- return create_possibly_reversed_range (type, new_lb, new_ub);
+ r = value_range (type);
+ else
+ {
+ wide_int new_lb = wide_int::from (prod0, prec, sign);
+ wide_int new_ub = wide_int::from (prod3, prec, sign);
+ create_possibly_reversed_range (r, type, new_lb, new_ub);
+ }
}
{
public:
operator_div (enum tree_code c) { code = c; }
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res, tree type,
const wide_int &, const wide_int &) const;
private:
return overflow;
}
-value_range
-operator_div::wi_fold (tree type,
+void
+operator_div::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
// If we know we will divide by zero, return undefined.
if (rh_lb == 0 && rh_ub == 0)
- return value_range ();
+ {
+ r = value_range ();
+ return;
+ }
const wide_int dividend_min = lh_lb;
const wide_int dividend_max = lh_ub;
// If we know we won't divide by zero, just do the division.
if (!wi_includes_zero_p (type, divisor_min, divisor_max))
- return wi_cross_product (type, dividend_min, dividend_max,
- divisor_min, divisor_max);
+ {
+ wi_cross_product (r, type, dividend_min, dividend_max,
+ divisor_min, divisor_max);
+ return;
+ }
// If flag_non_call_exceptions, we must not eliminate a division by zero.
if (cfun->can_throw_non_call_exceptions)
- return value_range (type);
+ {
+ r = value_range (type);
+ return;
+ }
// If we're definitely dividing by zero, there's nothing to do.
if (wi_zero_p (type, divisor_min, divisor_max))
- return value_range ();
+ {
+ r = value_range ();
+ return;
+ }
// Perform the division in 2 parts, [LB, -1] and [1, UB], which will
// skip any division by zero.
// First divide by the negative numbers, if any.
- value_range r;
if (wi::neg_p (divisor_min, sign))
- r = wi_cross_product (type, dividend_min, dividend_max,
- divisor_min, wi::minus_one (prec));
+ wi_cross_product (r, type, dividend_min, dividend_max,
+ divisor_min, wi::minus_one (prec));
+ else
+ r = value_range ();
+
// Then divide by the non-zero positive numbers, if any.
if (wi::gt_p (divisor_max, wi::zero (prec), sign))
{
value_range tmp;
- tmp = wi_cross_product (type, dividend_min, dividend_max,
- wi::one (prec), divisor_max);
+ wi_cross_product (tmp, type, dividend_min, dividend_max,
+ wi::one (prec), divisor_max);
r.union_ (tmp);
}
- return r;
+ // We shouldn't still have undefined here.
+ gcc_checking_assert (!r.undefined_p ());
}
operator_div op_trunc_div (TRUNC_DIV_EXPR);
-operator_div op_floor_div(FLOOR_DIV_EXPR);
+operator_div op_floor_div (FLOOR_DIV_EXPR);
operator_div op_round_div (ROUND_DIV_EXPR);
operator_div op_ceil_div (CEIL_DIV_EXPR);
if (op2.singleton_p (&offset)
&& !integer_zerop (offset))
{
- r = range_op_handler (MULT_EXPR, type)->fold_range (type, lhs, op2);
+ range_op_handler (MULT_EXPR, type)->fold_range (r, type, lhs, op2);
return true;
}
return false;
class operator_lshift : public cross_product_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb, const wide_int &lh_ub,
+ const wide_int &rh_lb, const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res,
tree type,
const wide_int &,
const wide_int &) const;
} op_lshift;
-value_range
-operator_lshift::fold_range (tree type,
+void
+operator_lshift::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (undefined_shift_range_check (r, type, op2))
- return r;
+ return;
// Transform left shifts by constants into multiplies.
if (op2.singleton_p ())
bool saved_flag_wrapv_pointer = flag_wrapv_pointer;
flag_wrapv = 1;
flag_wrapv_pointer = 1;
- r = range_op_handler (MULT_EXPR, type)->fold_range (type, op1, mult);
+ range_op_handler (MULT_EXPR, type)->fold_range (r, type, op1, mult);
flag_wrapv = saved_flag_wrapv;
flag_wrapv_pointer = saved_flag_wrapv_pointer;
- return r;
+ return;
}
// Otherwise, invoke the generic fold routine.
- return range_operator::fold_range (type, op1, op2);
+ range_operator::fold_range (r, type, op1, op2);
}
-value_range
-operator_lshift::wi_fold (tree type,
+void
+operator_lshift::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
}
if (in_bounds)
- return wi_cross_product (type, lh_lb, lh_ub, rh_lb, rh_ub);
-
- return value_range (type);
+ wi_cross_product (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ else
+ r = value_range (type);
}
bool
class operator_rshift : public cross_product_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res,
tree type,
const wide_int &w0,
return false;
}
-value_range
-operator_rshift::fold_range (tree type,
+void
+operator_rshift::fold_range (value_range &r, tree type,
const value_range &op1,
const value_range &op2) const
{
- value_range r;
if (undefined_shift_range_check (r, type, op2))
- return r;
+ return;
// Otherwise, invoke the generic fold routine.
- return range_operator::fold_range (type, op1, op2);
+ range_operator::fold_range (r, type, op1, op2);
}
-value_range
-operator_rshift::wi_fold (tree type,
+void
+operator_rshift::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
- return wi_cross_product (type, lh_lb, lh_ub, rh_lb, rh_ub);
+ wi_cross_product (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
}
class operator_cast: public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_convert;
-value_range
-operator_cast::fold_range (tree type ATTRIBUTE_UNUSED,
+void
+operator_cast::fold_range (value_range &r, tree type ATTRIBUTE_UNUSED,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
-
+ return;
+
tree inner = lh.type ();
tree outer = rh.type ();
gcc_checking_assert (rh.varying_p ());
unsigned inner_prec = TYPE_PRECISION (inner);
unsigned outer_prec = TYPE_PRECISION (outer);
+ // Start with an empty range and add subranges.
+ r = value_range ();
for (unsigned x = 0; x < lh.num_pairs (); ++x)
{
wide_int lh_lb = lh.lower_bound (x);
|| !wi::eq_p (max, wi::max_value (outer_prec, outer_sign)))
{
value_range tmp;
- tmp = create_possibly_reversed_range (type, min, max);
+ create_possibly_reversed_range (tmp, type, min, max);
r.union_ (tmp);
continue;
}
}
- return value_range (type);
+ r = value_range (type);
+ return;
}
- return r;
}
bool
const value_range &op2) const
{
tree lhs_type = lhs.type ();
+ value_range tmp;
gcc_checking_assert (types_compatible_p (op2.type(), type));
// If the precision of the LHS is smaller than the precision of the
// If we've been passed an actual value for the RHS rather than
// the type, see if it fits the LHS, and if so, then we can allow
// it.
- r = op2;
- r = fold_range (lhs_type, r, value_range (lhs_type));
- r = fold_range (type, r, value_range (type));
- if (r == op2)
+ fold_range (r, lhs_type, op2, value_range (lhs_type));
+ fold_range (tmp, type, r, value_range (type));
+ if (tmp == op2)
{
// We know the value of the RHS fits in the LHS type, so
// convert the LHS and remove any values that arent in OP2.
- r = lhs;
- r = fold_range (type, r, value_range (type));
+ fold_range (r, type, lhs, value_range (type));
r.intersect (op2);
return true;
}
if (TYPE_PRECISION (lhs_type) > TYPE_PRECISION (type))
{
// Cast the range of the RHS to the type of the LHS.
- value_range op_type (type);
- op_type = fold_range (lhs_type, op_type, value_range (lhs_type));
-
- // Intersect this with the LHS range will produce the RHS range.
- r = range_intersect (lhs, op_type);
+ fold_range (tmp, lhs_type, value_range (type), value_range (lhs_type));
+ // Intersect this with the LHS range will produce the range, which
+ // will be cast to the RHS type before returning.
+ tmp.intersect (lhs);
}
else
- r = lhs;
+ tmp = lhs;
// Cast the calculated range to the type of the RHS.
- r = fold_range (type, r, value_range (type));
+ fold_range (r, type, tmp, value_range (type));
return true;
}
class operator_logical_and : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &lh,
- const value_range &rh) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &lh,
+ const value_range &rh) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_logical_and;
-value_range
-operator_logical_and::fold_range (tree type,
+void
+operator_logical_and::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
// 0 && anything is 0.
if ((wi::eq_p (lh.lower_bound (), 0) && wi::eq_p (lh.upper_bound (), 0))
|| (wi::eq_p (lh.lower_bound (), 0) && wi::eq_p (rh.upper_bound (), 0)))
- return range_false (type);
-
- // To reach this point, there must be a logical 1 on each side, and
- // the only remaining question is whether there is a zero or not.
- if (lh.contains_p (build_zero_cst (lh.type ()))
- || rh.contains_p (build_zero_cst (rh.type ())))
- return range_true_and_false (type);
-
- return range_true (type);
+ r = range_false (type);
+ else if (lh.contains_p (build_zero_cst (lh.type ()))
+ || rh.contains_p (build_zero_cst (rh.type ())))
+ // To reach this point, there must be a logical 1 on each side, and
+ // the only remaining question is whether there is a zero or not.
+ r = range_true_and_false (type);
+ else
+ r = range_true (type);
}
bool
virtual bool op2_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op1) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_and;
// Optimize BIT_AND_EXPR and BIT_IOR_EXPR in terms of a mask if
}
else
gcc_unreachable ();
- r = value_range_with_overflow (type, res_lb, res_ub);
+ value_range_with_overflow (r, type, res_lb, res_ub);
return true;
}
}
}
-value_range
-operator_bitwise_and::wi_fold (tree type,
+void
+operator_bitwise_and::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
- value_range r;
if (wi_optimize_and_or (r, BIT_AND_EXPR, type, lh_lb, lh_ub, rh_lb, rh_ub))
- return r;
+ return;
wide_int maybe_nonzero_lh, mustbe_nonzero_lh;
wide_int maybe_nonzero_rh, mustbe_nonzero_rh;
}
// If the limits got swapped around, return varying.
if (wi::gt_p (new_lb, new_ub,sign))
- return value_range (type);
-
- return value_range_with_overflow (type, new_lb, new_ub);
+ r = value_range (type);
+ else
+ value_range_with_overflow (r, type, new_lb, new_ub);
}
bool
class operator_logical_or : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &lh,
- const value_range &rh) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &lh,
+ const value_range &rh) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
const value_range &op1) const;
} op_logical_or;
-value_range
-operator_logical_or::fold_range (tree type ATTRIBUTE_UNUSED,
+void
+operator_logical_or::fold_range (value_range &r, tree type ATTRIBUTE_UNUSED,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
- return range_union (lh, rh);
+ r = range_union (lh, rh);
}
bool
virtual bool op2_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op1) const;
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_or;
-value_range
-operator_bitwise_or::wi_fold (tree type,
+void
+operator_bitwise_or::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
- value_range r;
if (wi_optimize_and_or (r, BIT_IOR_EXPR, type, lh_lb, lh_ub, rh_lb, rh_ub))
- return r;
+ return;
wide_int maybe_nonzero_lh, mustbe_nonzero_lh;
wide_int maybe_nonzero_rh, mustbe_nonzero_rh;
new_lb = wi::max (new_lb, rh_lb, sign);
// If the limits got swapped around, return varying.
if (wi::gt_p (new_lb, new_ub,sign))
- return value_range (type);
-
- return value_range_with_overflow (type, new_lb, new_ub);
+ r = value_range (type);
+ else
+ value_range_with_overflow (r, type, new_lb, new_ub);
}
bool
class operator_bitwise_xor : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_xor;
-value_range
-operator_bitwise_xor::wi_fold (tree type,
+void
+operator_bitwise_xor::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
// If the range has all positive or all negative values, the result
// is better than VARYING.
if (wi::lt_p (new_lb, 0, sign) || wi::ge_p (new_ub, 0, sign))
- return value_range_with_overflow (type, new_lb, new_ub);
-
- return value_range (type);
+ value_range_with_overflow (r, type, new_lb, new_ub);
+ else
+ r = value_range (type);
}
class operator_trunc_mod : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_trunc_mod;
-value_range
-operator_trunc_mod::wi_fold (tree type,
+void
+operator_trunc_mod::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
// Mod 0 is undefined. Return undefined.
if (wi_zero_p (type, rh_lb, rh_ub))
- return value_range ();
+ {
+ r = value_range ();
+ return;
+ }
// ABS (A % B) < ABS (B) and either 0 <= A % B <= A or A <= A % B <= 0.
new_ub = rh_ub - 1;
tmp = wi::zero (prec);
new_ub = wi::min (new_ub, tmp, sign);
- return value_range_with_overflow (type, new_lb, new_ub);
+ value_range_with_overflow (r, type, new_lb, new_ub);
}
class operator_logical_not : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &lh,
- const value_range &rh) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &lh,
+ const value_range &rh) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
// b_2 = x_1 < 20 [0,0] = x_1 < 20, false, so x_1 == [20, 255]
// which is the result we are looking for.. so.. pass it through.
-value_range
-operator_logical_not::fold_range (tree type,
+void
+operator_logical_not::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh ATTRIBUTE_UNUSED) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
if (lh.varying_p () || lh.undefined_p ())
r = lh;
else
r = range_invert (lh);
gcc_checking_assert (lh.type() == type);
- return r;
+ return;
}
bool
class operator_bitwise_not : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &lh,
- const value_range &rh) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &lh,
+ const value_range &rh) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_bitwise_not;
-value_range
-operator_bitwise_not::fold_range (tree type,
+void
+operator_bitwise_not::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
// ~X is simply -1 - X.
value_range minusone (type, wi::minus_one (TYPE_PRECISION (type)),
wi::minus_one (TYPE_PRECISION (type)));
- r = range_op_handler (MINUS_EXPR, type)->fold_range (type, minusone, lh);
- return r;
+ range_op_handler (MINUS_EXPR, type)->fold_range (r, type, minusone, lh);
+ return;
}
bool
const value_range &op2) const
{
// ~X is -1 - X and since bitwise NOT is involutary...do it again.
- r = fold_range (type, lhs, op2);
+ fold_range (r, type, lhs, op2);
return true;
}
class operator_cst : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
} op_integer_cst;
-value_range
-operator_cst::fold_range (tree type ATTRIBUTE_UNUSED,
+void
+operator_cst::fold_range (value_range &r, tree type ATTRIBUTE_UNUSED,
const value_range &lh,
const value_range &rh ATTRIBUTE_UNUSED) const
{
- return lh;
+ r = lh;
}
class operator_identity : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_identity;
-value_range
-operator_identity::fold_range (tree type ATTRIBUTE_UNUSED,
+void
+operator_identity::fold_range (value_range &r, tree type ATTRIBUTE_UNUSED,
const value_range &lh,
const value_range &rh ATTRIBUTE_UNUSED) const
{
- return lh;
+ r = lh;
}
bool
class operator_abs : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_abs;
-value_range
-operator_abs::wi_fold (tree type,
+void
+operator_abs::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
const wide_int &rh_ub ATTRIBUTE_UNUSED) const
// Pass through LH for the easy cases.
if (sign == UNSIGNED || wi::ge_p (lh_lb, 0, sign))
- return value_range (type, lh_lb, lh_ub);
+ {
+ r = value_range (type, lh_lb, lh_ub);
+ return;
+ }
// -TYPE_MIN_VALUE = TYPE_MIN_VALUE with flag_wrapv so we can't get
// a useful range.
wide_int min_value = wi::min_value (prec, sign);
wide_int max_value = wi::max_value (prec, sign);
if (!TYPE_OVERFLOW_UNDEFINED (type) && wi::eq_p (lh_lb, min_value))
- return value_range (type);
+ {
+ r = value_range (type, lh_lb, lh_ub);
+ return;
+ }
// ABS_EXPR may flip the range around, if the original range
// included negative values.
min = wi::zero (prec);
max = max_value;
}
- return value_range (type, min, max);
+ r = value_range (type, min, max);
}
bool
class operator_absu : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb, const wide_int &lh_ub,
+ const wide_int &rh_lb, const wide_int &rh_ub) const;
} op_absu;
-value_range
-operator_absu::wi_fold (tree type,
+void
+operator_absu::wi_fold (value_range &r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
const wide_int &rh_ub ATTRIBUTE_UNUSED) const
}
gcc_checking_assert (TYPE_UNSIGNED (type));
- return value_range (type, new_lb, new_ub);
+ r = value_range (type, new_lb, new_ub);
}
class operator_negate : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_negate;
-value_range
-operator_negate::fold_range (tree type,
+void
+operator_negate::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
// -X is simply 0 - X.
- return
- range_op_handler (MINUS_EXPR, type)->fold_range (type,
- range_zero (type), lh);
+ range_op_handler (MINUS_EXPR, type)->fold_range (r, type,
+ range_zero (type), lh);
}
bool
const value_range &op2) const
{
// NEGATE is involutory.
- r = fold_range (type, lhs, op2);
+ fold_range (r, type, lhs, op2);
return true;
}
class operator_addr_expr : public range_operator
{
public:
- virtual value_range fold_range (tree type,
- const value_range &op1,
- const value_range &op2) const;
+ virtual void fold_range (value_range &r, tree type,
+ const value_range &op1,
+ const value_range &op2) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
} op_addr;
-value_range
-operator_addr_expr::fold_range (tree type,
+void
+operator_addr_expr::fold_range (value_range &r, tree type,
const value_range &lh,
const value_range &rh) const
{
- value_range r;
if (empty_range_check (r, lh, rh))
- return r;
+ return;
// Return a non-null pointer of the LHS type (passed in op2).
if (lh.zero_p ())
- return range_zero (type);
- if (!lh.contains_p (build_zero_cst (lh.type ())))
- return range_nonzero (type);
- return value_range (type);
+ r = range_zero (type);
+ else if (!lh.contains_p (build_zero_cst (lh.type ())))
+ r = range_nonzero (type);
+ else
+ r = value_range (type);
}
bool
const value_range &lhs,
const value_range &op2) const
{
- r = operator_addr_expr::fold_range (type, lhs, op2);
+ operator_addr_expr::fold_range (r, type, lhs, op2);
return true;
}
class pointer_plus_operator : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_pointer_plus;
-value_range
-pointer_plus_operator::wi_fold (tree type,
+void
+pointer_plus_operator::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
&& !TYPE_OVERFLOW_WRAPS (type)
&& (flag_delete_null_pointer_checks
|| !wi::sign_mask (rh_ub)))
- return range_nonzero (type);
- if (lh_lb == lh_ub && lh_lb == 0
- && rh_lb == rh_ub && rh_lb == 0)
- return range_zero (type);
- return value_range (type);
+ r = range_nonzero (type);
+ else if (lh_lb == lh_ub && lh_lb == 0
+ && rh_lb == rh_ub && rh_lb == 0)
+ r = range_zero (type);
+ else
+ r = value_range (type);
}
class pointer_min_max_operator : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range & r, tree type,
+ const wide_int &lh_lb, const wide_int &lh_ub,
+ const wide_int &rh_lb, const wide_int &rh_ub) const;
} op_ptr_min_max;
-value_range
-pointer_min_max_operator::wi_fold (tree type,
+void
+pointer_min_max_operator::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
// are varying.
if (!wi_includes_zero_p (type, lh_lb, lh_ub)
&& !wi_includes_zero_p (type, rh_lb, rh_ub))
- return range_nonzero (type);
- if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
- return range_zero (type);
- return value_range (type);
+ r = range_nonzero (type);
+ else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
+ r = range_zero (type);
+ else
+ r = value_range (type);
}
class pointer_and_operator : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb, const wide_int &lh_ub,
+ const wide_int &rh_lb, const wide_int &rh_ub) const;
} op_pointer_and;
-value_range
-pointer_and_operator::wi_fold (tree type,
+void
+pointer_and_operator::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
// For pointer types, we are really only interested in asserting
// whether the expression evaluates to non-NULL.
if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub))
- return range_zero (type);
-
- return value_range (type);
+ r = range_zero (type);
+ else
+ r = value_range (type);
}
class pointer_or_operator : public range_operator
{
public:
- virtual value_range wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual void wi_fold (value_range &r, tree type,
+ const wide_int &lh_lb, const wide_int &lh_ub,
+ const wide_int &rh_lb, const wide_int &rh_ub) const;
} op_pointer_or;
-value_range
-pointer_or_operator::wi_fold (tree type,
+void
+pointer_or_operator::wi_fold (value_range &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
// whether the expression evaluates to non-NULL.
if (!wi_includes_zero_p (type, lh_lb, lh_ub)
&& !wi_includes_zero_p (type, rh_lb, rh_ub))
- return range_nonzero (type);
- if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
- return range_zero (type);
- return value_range (type);
+ r = range_nonzero (type);
+ else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
+ r = range_zero (type);
+ else
+ r = value_range (type);
}
\f
// This implements the range operator tables as local objects in this file.
void
range_cast (value_range &r, tree type)
{
+ value_range tmp = r;
range_operator *op = range_op_handler (CONVERT_EXPR, type);
- r = op->fold_range (type, r, value_range (type));
+ op->fold_range (r, type, tmp, value_range (type));
}
#if CHECKING_P