static inline void
frange_drop_inf (frange &r, tree type)
{
- REAL_VALUE_TYPE max;
- real_max_representable (&max, type);
+ REAL_VALUE_TYPE max = real_max_representable (type);
frange tmp (type, r.lower_bound (), max);
r.intersect (tmp);
}
static inline void
frange_drop_ninf (frange &r, tree type)
{
- REAL_VALUE_TYPE min;
- real_min_representable (&min, type);
+ REAL_VALUE_TYPE min = real_min_representable (type);
frange tmp (type, min, r.upper_bound ());
r.intersect (tmp);
}
{
gcc_checking_assert (!val.known_isnan ());
- r.set (type, dconstninf, val.upper_bound ());
+ REAL_VALUE_TYPE ninf = frange_val_min (type);
+ r.set (type, ninf, val.upper_bound ());
// Add both zeros if there's the possibility of zero equality.
frange_add_zeros (r, type);
return false;
}
// We only support closed intervals.
- r.set (type, dconstninf, val.upper_bound ());
+ REAL_VALUE_TYPE ninf = frange_val_min (type);
+ r.set (type, ninf, val.upper_bound ());
return true;
}
{
gcc_checking_assert (!val.known_isnan ());
- r.set (type, val.lower_bound (), dconstinf);
+ REAL_VALUE_TYPE inf = frange_val_max (type);
+ r.set (type, val.lower_bound (), inf);
// Add both zeros if there's the possibility of zero equality.
frange_add_zeros (r, type);
}
// We only support closed intervals.
- r.set (type, val.lower_bound (), dconstinf);
+ REAL_VALUE_TYPE inf = frange_val_max (type);
+ r.set (type, val.lower_bound (), inf);
return true;
}
m_neg_nan = false;
}
+ // For -ffinite-math-only we can drop ranges outside the
+ // representable numbers to min/max for the type.
+ if (flag_finite_math_only)
+ {
+ REAL_VALUE_TYPE min_repr = frange_val_min (m_type);
+ REAL_VALUE_TYPE max_repr = frange_val_max (m_type);
+ if (real_less (&m_min, &min_repr))
+ m_min = min_repr;
+ if (real_less (&max_repr, &m_max))
+ m_max = max_repr;
+ }
+
// Check for swapped ranges.
gcc_checking_assert (tree_compare (LE_EXPR, min, max));
frange::normalize_kind ()
{
if (m_kind == VR_RANGE
- && real_isinf (&m_min, 1)
- && real_isinf (&m_max, 0))
+ && frange_val_is_min (m_min, m_type)
+ && frange_val_is_max (m_max, m_type))
{
if (m_pos_nan && m_neg_nan)
{
if (!m_pos_nan || !m_neg_nan)
{
m_kind = VR_RANGE;
- m_min = dconstninf;
- m_max = dconstinf;
+ m_min = frange_val_min (m_type);
+ m_max = frange_val_max (m_type);
return true;
}
}
case VR_VARYING:
gcc_checking_assert (m_type);
gcc_checking_assert (m_pos_nan && m_neg_nan);
- gcc_checking_assert (real_isinf (&m_min, 1));
- gcc_checking_assert (real_isinf (&m_max, 0));
+ gcc_checking_assert (frange_val_is_min (m_min, m_type));
+ gcc_checking_assert (frange_val_is_max (m_max, m_type));
return;
case VR_RANGE:
gcc_checking_assert (m_type);
// If all the properties are clear, we better not span the entire
// domain, because that would make us varying.
if (m_pos_nan && m_neg_nan)
- gcc_checking_assert (!real_isinf (&m_min, 1) || !real_isinf (&m_max, 0));
+ gcc_checking_assert (!frange_val_is_min (m_min, m_type)
+ || !frange_val_is_max (m_max, m_type));
}
// We can't do much with nonzeros yet.
void
frange::set_nonnegative (tree type)
{
- set (type, dconst0, dconstinf);
+ set (type, dconst0, frange_val_max (type));
// Set +NAN as the only possibility.
if (HONOR_NANS (type))
r0.clear_nan ();
ASSERT_FALSE (r0.varying_p ());
- // The endpoints of a VARYING are +-INF.
- r0.set_varying (float_type_node);
- ASSERT_TRUE (real_identical (&r0.lower_bound (), &dconstninf));
- ASSERT_TRUE (real_identical (&r0.upper_bound (), &dconstinf));
-
- // The maximum representable range for a type is still a subset of VARYING.
- REAL_VALUE_TYPE q, r;
- real_min_representable (&q, float_type_node);
- real_max_representable (&r, float_type_node);
- r0 = frange (float_type_node, q, r);
- // r0 is not a varying, because it does not include -INF/+INF.
- ASSERT_FALSE (r0.varying_p ());
- // The upper bound of r0 must be less than +INF.
- ASSERT_TRUE (real_less (&r0.upper_bound (), &dconstinf));
- // The lower bound of r0 must be greater than -INF.
- ASSERT_TRUE (real_less (&dconstninf, &r0.lower_bound ()));
-
// For most architectures, where float and double are different
// sizes, having the same endpoints does not necessarily mean the
// ranges are equal.
extern bool vrp_val_is_min (const_tree);
extern bool vrp_val_is_max (const_tree);
extern bool vrp_operand_equal_p (const_tree, const_tree);
+inline REAL_VALUE_TYPE frange_val_min (const_tree type);
+inline REAL_VALUE_TYPE frange_val_max (const_tree type);
inline value_range_kind
vrange::kind () const
return wide_int_to_tree (const_cast<tree> (type), max);
}
if (frange::supports_p (type))
- return build_real (const_cast <tree> (type), dconstinf);
+ {
+ REAL_VALUE_TYPE r = frange_val_max (type);
+ return build_real (const_cast <tree> (type), r);
+ }
return NULL_TREE;
}
if (POINTER_TYPE_P (type))
return build_zero_cst (const_cast<tree> (type));
if (frange::supports_p (type))
- return build_real (const_cast <tree> (type), dconstninf);
+ {
+ REAL_VALUE_TYPE r = frange_val_min (type);
+ return build_real (const_cast <tree> (type), r);
+ }
return NULL_TREE;
}
{
m_kind = VR_VARYING;
m_type = type;
- m_min = dconstninf;
- m_max = dconstinf;
+ m_min = frange_val_min (type);
+ m_max = frange_val_max (type);
m_pos_nan = true;
m_neg_nan = true;
}
// Set R to maximum representable value for TYPE.
-inline void
-real_max_representable (REAL_VALUE_TYPE *r, tree type)
+inline REAL_VALUE_TYPE
+real_max_representable (const_tree type)
{
+ REAL_VALUE_TYPE r;
char buf[128];
get_max_float (REAL_MODE_FORMAT (TYPE_MODE (type)),
buf, sizeof (buf), false);
- int res = real_from_string (r, buf);
+ int res = real_from_string (&r, buf);
gcc_checking_assert (!res);
+ return r;
}
-// Set R to minimum representable value for TYPE.
+// Return the minimum representable value for TYPE.
-inline void
-real_min_representable (REAL_VALUE_TYPE *r, tree type)
+inline REAL_VALUE_TYPE
+real_min_representable (const_tree type)
+{
+ REAL_VALUE_TYPE r = real_max_representable (type);
+ r = real_value_negate (&r);
+ return r;
+}
+
+// Return the minimum value for TYPE.
+
+inline REAL_VALUE_TYPE
+frange_val_min (const_tree type)
+{
+ if (flag_finite_math_only)
+ return real_min_representable (type);
+ else
+ return dconstninf;
+}
+
+// Return the maximum value for TYPE.
+
+inline REAL_VALUE_TYPE
+frange_val_max (const_tree type)
+{
+ if (flag_finite_math_only)
+ return real_max_representable (type);
+ else
+ return dconstinf;
+}
+
+// Return TRUE if R is the minimum value for TYPE.
+
+inline bool
+frange_val_is_min (const REAL_VALUE_TYPE &r, const_tree type)
+{
+ REAL_VALUE_TYPE min = frange_val_min (type);
+ return real_identical (&min, &r);
+}
+
+// Return TRUE if R is the max value for TYPE.
+
+inline bool
+frange_val_is_max (const REAL_VALUE_TYPE &r, const_tree type)
{
- real_max_representable (r, type);
- *r = real_value_negate (r);
+ REAL_VALUE_TYPE max = frange_val_max (type);
+ return real_identical (&max, &r);
}
// Build a signless NAN of type TYPE.