]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Unify LE_EXPR range operator
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 9 Jun 2023 17:30:56 +0000 (13:30 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Sat, 10 Jun 2023 00:33:02 +0000 (20:33 -0400)
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

* range-op-float.cc (foperator_le): Remove.  Move prototypes
to range-op-mixed.h
(operator_le::fold_range): Rename from foperator_le.
(operator_le::op1_range): Ditto.
(float_table::float_table): Remove LE_EXPR.
* range-op-mixed.h (class operator_le): Combined from integer
and float files.
* range-op.cc (op_le): New object.
(unified_table::unified_table): Add LE_EXPR.
(class operator_le): Move to range-op-mixed.h.
(le_op1_op2_relation): Fold into
operator_le::op1_op2_relation.
(integral_table::integral_table): Remove LE_EXPR.
(pointer_table::pointer_table): Remove LE_EXPR.
* range-op.h (le_op1_op2_relation): Delete.

gcc/range-op-float.cc
gcc/range-op-mixed.h
gcc/range-op.cc
gcc/range-op.h

index 1b0ac9a7fc2308a6310c21f8de0c2ca47390c6af..a480f1641d22a39f2bc6f3822b5b63025e5329d2 100644 (file)
@@ -873,32 +873,10 @@ operator_lt::op2_range (frange &r,
   return true;
 }
 
-class foperator_le : public range_operator
-{
-  using range_operator::fold_range;
-  using range_operator::op1_range;
-  using range_operator::op2_range;
-  using range_operator::op1_op2_relation;
-public:
-  bool fold_range (irange &r, tree type,
-                  const frange &op1, const frange &op2,
-                  relation_trio rel = TRIO_VARYING) const final override;
-  relation_kind op1_op2_relation (const irange &lhs) const final override
-  {
-    return le_op1_op2_relation (lhs);
-  }
-  bool op1_range (frange &r, tree type,
-                 const irange &lhs, const frange &op2,
-                 relation_trio rel = TRIO_VARYING) const final override;
-  bool op2_range (frange &r, tree type,
-                 const irange &lhs, const frange &op1,
-                 relation_trio rel = TRIO_VARYING) const final override;
-} fop_le;
-
 bool
-foperator_le::fold_range (irange &r, tree type,
-                         const frange &op1, const frange &op2,
-                         relation_trio rel) const
+operator_le::fold_range (irange &r, tree type,
+                        const frange &op1, const frange &op2,
+                        relation_trio rel) const
 {
   if (frelop_early_resolve (r, type, op1, op2, rel, VREL_LE))
     return true;
@@ -916,11 +894,11 @@ foperator_le::fold_range (irange &r, tree type,
 }
 
 bool
-foperator_le::op1_range (frange &r,
-                        tree type,
-                        const irange &lhs,
-                        const frange &op2,
-                        relation_trio) const
+operator_le::op1_range (frange &r,
+                       tree type,
+                       const irange &lhs,
+                       const frange &op2,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -949,11 +927,11 @@ foperator_le::op1_range (frange &r,
 }
 
 bool
-foperator_le::op2_range (frange &r,
-                        tree type,
-                        const irange &lhs,
-                        const frange &op1,
-                        relation_trio) const
+operator_le::op2_range (frange &r,
+                       tree type,
+                       const irange &lhs,
+                       const frange &op1,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -1637,7 +1615,8 @@ public:
       op1_no_nan.clear_nan ();
     if (op2.maybe_isnan ())
       op2_no_nan.clear_nan ();
-    if (!fop_le.fold_range (r, type, op1_no_nan, op2_no_nan, rel))
+    if (!range_op_handler (LE_EXPR).fold_range (r, type, op1_no_nan,
+                                               op2_no_nan, rel))
       return false;
     // The result is the same as the ordered version when the
     // comparison is true or when the operands cannot be NANs.
@@ -2765,7 +2744,6 @@ float_table::float_table ()
   // All the relational operators are expected to work, because the
   // calculation of ranges on outgoing edges expect the handlers to be
   // present.
-  set (LE_EXPR, fop_le);
   set (GT_EXPR, fop_gt);
   set (GE_EXPR, fop_ge);
 
index bc93ab5be06bfe82115bc628a16a73bcfa041518..dd42d98ca4986d3eaa5c6c52dc24be3e776b5d05 100644 (file)
@@ -171,4 +171,37 @@ public:
   void update_bitmask (irange &r, const irange &lh,
                       const irange &rh) const final override;
 };
+
+class operator_le :  public range_operator
+{
+public:
+  using range_operator::fold_range;
+  using range_operator::op1_range;
+  using range_operator::op2_range;
+  using range_operator::op1_op2_relation;
+  bool fold_range (irange &r, tree type,
+                  const irange &op1, const irange &op2,
+                  relation_trio = TRIO_VARYING) const final override;
+  bool fold_range (irange &r, tree type,
+                  const frange &op1, const frange &op2,
+                  relation_trio rel = TRIO_VARYING) const final override;
+
+  bool op1_range (irange &r, tree type,
+                 const irange &lhs, const irange &op2,
+                 relation_trio = TRIO_VARYING) const final override;
+  bool op1_range (frange &r, tree type,
+                 const irange &lhs, const frange &op2,
+                 relation_trio rel = TRIO_VARYING) const final override;
+
+  bool op2_range (irange &r, tree type,
+                 const irange &lhs, const irange &op1,
+                 relation_trio = TRIO_VARYING) const final override;
+  bool op2_range (frange &r, tree type,
+                 const irange &lhs, const frange &op1,
+                 relation_trio rel = TRIO_VARYING) const final override;
+
+  relation_kind op1_op2_relation (const irange &lhs) const final override;
+  void update_bitmask (irange &r, const irange &lh,
+                      const irange &rh) const final override;
+};
 #endif // GCC_RANGE_OP_MIXED_H
index 138779998478956cd9eb2ca2081d5f8a77eae6b8..c2e9927e774d2b71efbe16176ee0222e536abf24 100644 (file)
@@ -65,6 +65,7 @@ class unified_table : public range_op_table
 operator_equal op_equal;
 operator_not_equal op_not_equal;
 operator_lt op_lt;
+operator_le op_le;
 
 // Invoke the initialization routines for each class of range.
 
@@ -77,6 +78,7 @@ unified_table::unified_table ()
   set (EQ_EXPR, op_equal);
   set (NE_EXPR, op_not_equal);
   set (LT_EXPR, op_lt);
+  set (LE_EXPR, op_le);
 }
 
 // The tables are hidden and accessed via a simple extern function.
@@ -1192,34 +1194,17 @@ operator_lt::op2_range (irange &r, tree type,
 }
 
 
-class operator_le :  public range_operator
+void
+operator_le::update_bitmask (irange &r, const irange &lh,
+                            const irange &rh) const
 {
-  using range_operator::fold_range;
-  using range_operator::op1_range;
-  using range_operator::op2_range;
-  using range_operator::op1_op2_relation;
-public:
-  virtual bool fold_range (irange &r, tree type,
-                          const irange &op1,
-                          const irange &op2,
-                          relation_trio = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op2,
-                         relation_trio = TRIO_VARYING) const;
-  virtual bool op2_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op1,
-                         relation_trio = TRIO_VARYING) const;
-  virtual relation_kind op1_op2_relation (const irange &lhs) const;
-  void update_bitmask (irange &r, const irange &lh, const irange &rh) const
-    { update_known_bitmask (r, LE_EXPR, lh, rh); }
-} op_le;
+  update_known_bitmask (r, LE_EXPR, lh, rh);
+}
 
 // Check if the LHS range indicates a relation between OP1 and OP2.
 
 relation_kind
-le_op1_op2_relation (const irange &lhs)
+operator_le::op1_op2_relation (const irange &lhs) const
 {
   if (lhs.undefined_p ())
     return VREL_UNDEFINED;
@@ -1234,12 +1219,6 @@ le_op1_op2_relation (const irange &lhs)
   return VREL_VARYING;
 }
 
-relation_kind
-operator_le::op1_op2_relation (const irange &lhs) const
-{
-  return le_op1_op2_relation (lhs);
-}
-
 bool
 operator_le::fold_range (irange &r, tree type,
                         const irange &op1,
@@ -4826,7 +4805,6 @@ pointer_or_operator::wi_fold (irange &r, tree type,
 \f
 integral_table::integral_table ()
 {
-  set (LE_EXPR, op_le);
   set (GT_EXPR, op_gt);
   set (GE_EXPR, op_ge);
   set (PLUS_EXPR, op_plus);
@@ -4877,7 +4855,6 @@ pointer_table::pointer_table ()
   set (MIN_EXPR, op_ptr_min_max);
   set (MAX_EXPR, op_ptr_min_max);
 
-  set (LE_EXPR, op_le);
   set (GT_EXPR, op_gt);
   set (GE_EXPR, op_ge);
   set (SSA_NAME, op_ident);
index df1d8871b532e18a58cde7b9be426798fd169dcc..7d24b43a80e619dbb952269d8852b1f6af2744a1 100644 (file)
@@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type,
                                      wide_int &mustbe_nonzero);
 
 // op1_op2_relation methods that are the same across irange and frange.
-relation_kind le_op1_op2_relation (const irange &lhs);
 relation_kind gt_op1_op2_relation (const irange &lhs);
 relation_kind ge_op1_op2_relation (const irange &lhs);