]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Implement op[12]_range operators for PLUS_EXPR and MINUS_EXPR.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 9 Nov 2022 00:00:57 +0000 (01:00 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 9 Nov 2022 09:03:12 +0000 (10:03 +0100)
We can implement the op[12]_range entries for plus and minus in terms
of each other.  These are adapted from the integer versions.

gcc/ChangeLog:

* range-op-float.cc (foperator_plus::op1_range): New.
(foperator_plus::op2_range): New.
(foperator_minus::op1_range): New.
(foperator_minus::op2_range): New.

gcc/range-op-float.cc

index d52e971f84ebf5a5428d40985ef17035e4693078..44db81c1c1eca42b70de4e930aac74b61a84a225 100644 (file)
@@ -1862,6 +1862,29 @@ foperator_unordered_equal::op1_range (frange &r, tree type,
 
 class foperator_plus : public range_operator_float
 {
+  using range_operator_float::op1_range;
+  using range_operator_float::op2_range;
+public:
+  virtual bool op1_range (frange &r, tree type,
+                         const frange &lhs,
+                         const frange &op2,
+                         relation_trio = TRIO_VARYING) const final override
+  {
+    if (lhs.undefined_p ())
+      return false;
+    range_op_handler minus (MINUS_EXPR, type);
+    if (!minus)
+      return false;
+    return minus.fold_range (r, type, lhs, op2);
+  }
+  virtual bool op2_range (frange &r, tree type,
+                         const frange &lhs,
+                         const frange &op1,
+                         relation_trio = TRIO_VARYING) const final override
+  {
+    return op1_range (r, type, lhs, op1);
+  }
+private:
   void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan,
                tree type,
                const REAL_VALUE_TYPE &lh_lb,
@@ -1886,6 +1909,28 @@ class foperator_plus : public range_operator_float
 
 class foperator_minus : public range_operator_float
 {
+  using range_operator_float::op1_range;
+  using range_operator_float::op2_range;
+public:
+  virtual bool op1_range (frange &r, tree type,
+                         const frange &lhs,
+                         const frange &op2,
+                         relation_trio = TRIO_VARYING) const final override
+  {
+    if (lhs.undefined_p ())
+      return false;
+    return fop_plus.fold_range (r, type, lhs, op2);
+  }
+  virtual bool op2_range (frange &r, tree type,
+                         const frange &lhs,
+                         const frange &op1,
+                         relation_trio = TRIO_VARYING) const final override
+  {
+    if (lhs.undefined_p ())
+      return false;
+    return fold_range (r, type, op1, lhs);
+  }
+private:
   void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan,
                tree type,
                const REAL_VALUE_TYPE &lh_lb,