op1_op2_relation can be called for relops (bool = a < b) as well as regular binary operators (z = a + b). This patch adds the overloaded method for floating point results.
gcc/ChangeLog: * range-op-float.cc (range_operator_float::op1_op2_relation): New. (class foperator_equal): Add using. (class foperator_not_equal): Same. (class foperator_lt): Same. (class foperator_le): Same. (class foperator_gt): Same. (class foperator_ge): Same. * range-op.cc (range_op_handler::op1_op2_relation): New. * range-op.h (range_operator_float::op1_op2_relation): New. --- gcc/range-op-float.cc | 12 ++++++++++++ gcc/range-op.cc | 4 +++- gcc/range-op.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 229b9d23351..23e0f5ef4e2 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -160,6 +160,12 @@ range_operator_float::op1_op2_relation (const irange &lhs ATTRIBUTE_UNUSED) cons return VREL_VARYING; } +relation_kind +range_operator_float::op1_op2_relation (const frange &lhs ATTRIBUTE_UNUSED) const +{ + return VREL_VARYING; +} + // Return TRUE if OP1 is known to be free of NANs. static inline bool @@ -338,6 +344,7 @@ class foperator_equal : public range_operator_float using range_operator_float::fold_range; using range_operator_float::op1_range; using range_operator_float::op2_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -444,6 +451,7 @@ class foperator_not_equal : public range_operator_float { using range_operator_float::fold_range; using range_operator_float::op1_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -545,6 +553,7 @@ class foperator_lt : public range_operator_float using range_operator_float::fold_range; using range_operator_float::op1_range; using range_operator_float::op2_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -660,6 +669,7 @@ class foperator_le : public range_operator_float using range_operator_float::fold_range; using range_operator_float::op1_range; using range_operator_float::op2_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -767,6 +777,7 @@ class foperator_gt : public range_operator_float using range_operator_float::fold_range; using range_operator_float::op1_range; using range_operator_float::op2_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -882,6 +893,7 @@ class foperator_ge : public range_operator_float using range_operator_float::fold_range; using range_operator_float::op1_range; using range_operator_float::op2_range; + using range_operator_float::op1_op2_relation; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 16fa1f4f46d..f8255dd10a1 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -4476,7 +4476,9 @@ range_op_handler::op1_op2_relation (const vrange &lhs) const gcc_checking_assert (m_valid); if (m_int) return m_int->op1_op2_relation (as_a <irange> (lhs)); - return m_float->op1_op2_relation (as_a <irange> (lhs)); + if (is_a <irange> (lhs)) + return m_float->op1_op2_relation (as_a <irange> (lhs)); + return m_float->op1_op2_relation (as_a <frange> (lhs)); } // Cast the range in R to TYPE. diff --git a/gcc/range-op.h b/gcc/range-op.h index b2f063afb07..48adcecc7c6 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -160,6 +160,7 @@ public: const frange &op2, relation_kind = VREL_VARYING) const; virtual relation_kind op1_op2_relation (const irange &lhs) const; + virtual relation_kind op1_op2_relation (const frange &lhs) const; }; class range_op_handler -- 2.37.3