]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add op1_op2_relation for float operands.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 13 Oct 2022 06:08:26 +0000 (08:08 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 13 Oct 2022 12:16:05 +0000 (14:16 +0200)
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
gcc/range-op.cc
gcc/range-op.h

index 229b9d233516dd914e70af3ac7645593163cabb1..23e0f5ef4e23724828c303d2ab327e95a3b74abc 100644 (file)
@@ -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,
index 16fa1f4f46daa6eafb62754d56083c423c8de46d..f8255dd10a190093b7abf8c653dc4056c254663e 100644 (file)
@@ -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.
index b2f063afb07475337e7fe9f6c4aa7ab51d9a4069..48adcecc7c68010a16b53866471745aa4c7a3079 100644 (file)
@@ -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