Since NANs can't appear in ranges for !HONOR_NANS, there's no reason to set them in a VARYING range.
gcc/ChangeLog: * value-range.h (frange::set_varying): Do not set NAN flags for !HONOR_NANS. * value-range.cc (frange::normalize_kind): Adjust for no NAN when !HONOR_NANS. (frange::verify_range): Same. * range-op-float.cc (maybe_isnan): Remove flag_finite_math_only check. --- gcc/range-op-float.cc | 3 --- gcc/value-range.cc | 11 ++++++++--- gcc/value-range.h | 12 ++++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 2a4a99ba467..a9e74c86877 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -171,9 +171,6 @@ range_operator_float::op1_op2_relation (const frange &lhs ATTRIBUTE_UNUSED) cons static inline bool maybe_isnan (const frange &op1, const frange &op2) { - if (flag_finite_math_only) - return false; - return op1.maybe_isnan () || op2.maybe_isnan (); } diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 511cd0ad767..bcda4987307 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -388,7 +388,7 @@ frange::normalize_kind () && frange_val_is_min (m_min, m_type) && frange_val_is_max (m_max, m_type)) { - if (m_pos_nan && m_neg_nan) + if (!HONOR_NANS (m_type) || (m_pos_nan && m_neg_nan)) { set_varying (m_type); return true; @@ -396,7 +396,7 @@ frange::normalize_kind () } else if (m_kind == VR_VARYING) { - if (!m_pos_nan || !m_neg_nan) + if (HONOR_NANS (m_type) && (!m_pos_nan || !m_neg_nan)) { m_kind = VR_RANGE; m_min = frange_val_min (m_type); @@ -712,14 +712,19 @@ frange::supports_type_p (const_tree type) const void frange::verify_range () { + if (flag_finite_math_only) + gcc_checking_assert (!maybe_isnan ()); switch (m_kind) { case VR_UNDEFINED: gcc_checking_assert (!m_type); return; case VR_VARYING: + if (flag_finite_math_only) + gcc_checking_assert (!m_pos_nan && !m_neg_nan); + else + gcc_checking_assert (m_pos_nan && m_neg_nan); gcc_checking_assert (m_type); - gcc_checking_assert (m_pos_nan && m_neg_nan); gcc_checking_assert (frange_val_is_min (m_min, m_type)); gcc_checking_assert (frange_val_is_max (m_max, m_type)); return; diff --git a/gcc/value-range.h b/gcc/value-range.h index 60b989b2b50..b48542a68aa 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -1103,8 +1103,16 @@ frange::set_varying (tree type) m_type = type; m_min = frange_val_min (type); m_max = frange_val_max (type); - m_pos_nan = true; - m_neg_nan = true; + if (HONOR_NANS (m_type)) + { + m_pos_nan = true; + m_neg_nan = true; + } + else + { + m_pos_nan = false; + m_neg_nan = false; + } } inline void -- 2.37.3