}
-// Called when there is either an overflow OR an underflow... which
-// means an anti range must be created to compensate. This does not
-// cover the case where there are 2 possible overflows, or none.
+// Create and return a range from a pair of wide-ints that are known
+// to have overflowed (or underflowed).
static value_range_base
-adjust_overflow_bound (tree type, const wide_int &wmin, const wide_int &wmax)
+value_range_from_overflowed_bounds (tree type,
+ const wide_int &wmin,
+ const wide_int &wmax)
{
const signop sgn = TYPE_SIGN (type);
const unsigned int prec = TYPE_PRECISION (type);
return value_range_base (VR_ANTI_RANGE, type, tmin, tmax);
}
-// Given a newly calculated lbound and ubound, examine their
-// respective overflow bits to determine how to create a range.
-// Return said range.
+// 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_base
-create_range_with_overflow (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)
+value_range_with_overflow (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)
{
const signop sgn = TYPE_SIGN (type);
const unsigned int prec = TYPE_PRECISION (type);
if ((min_ovf == wi::OVF_UNDERFLOW && max_ovf == wi::OVF_NONE)
|| (max_ovf == wi::OVF_OVERFLOW && min_ovf == wi::OVF_NONE))
- return adjust_overflow_bound (type, wmin, wmax);
+ return value_range_from_overflowed_bounds (type, wmin, wmax);
// Other underflow and/or overflow, drop to VR_VARYING.
return value_range_base (type);
}
}
-// Like above, but canonicalize the case where the bounds are swapped
-// and overflow may wrap. In which case, we transform [10,5] into
-// [MIN,5][10,MAX].
+// Create and return a range from a pair of wide-ints. Canonicalize
+// the case where the bounds are swapped. In which case, we transform
+// [10,5] into [MIN,5][10,MAX].
static inline value_range_base
create_possibly_reversed_range (tree type,
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 adjust_overflow_bound (type, new_lb, new_ub);
+ return value_range_from_overflowed_bounds (type, new_lb, new_ub);
// Otherwise its just a normal range.
return value_range_base (type, new_lb, new_ub);
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 create_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
+ return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
}
bool
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 create_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
+ return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub);
}
bool
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 create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
}
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 create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
}
// 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 create_range_with_overflow (type, res_lb, res_ub);
+ return value_range_with_overflow (type, res_lb, res_ub);
}
}
else
gcc_unreachable ();
- r = create_range_with_overflow (type, res_lb, res_ub);
+ r = value_range_with_overflow (type, res_lb, res_ub);
return true;
}
if (wi::gt_p (new_lb, new_ub,sign))
return value_range_base (type);
- return create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
}
bool
if (wi::gt_p (new_lb, new_ub,sign))
return value_range_base (type);
- return create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
}
bool
// 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 create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
return value_range_base (type);
}
tmp = wi::zero (prec);
new_ub = wi::min (new_ub, tmp, sign);
- return create_range_with_overflow (type, new_lb, new_ub);
+ return value_range_with_overflow (type, new_lb, new_ub);
}