]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Unify GE_EXPR range operator
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 9 Jun 2023 17:33:33 +0000 (13:33 -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_ge): Remove.  Move prototypes
to range-op-mixed.h
(operator_ge::fold_range): Rename from foperator_ge.
(operator_ge::op1_range): Ditto.
(float_table::float_table): Remove GE_EXPR.
* range-op-mixed.h (class operator_ge): Combined from integer
and float files.
* range-op.cc (op_ge): New object.
(unified_table::unified_table): Add GE_EXPR.
(class operator_ge): Move to range-op-mixed.h.
(ge_op1_op2_relation): Fold into
operator_ge::op1_op2_relation.
(integral_table::integral_table): Remove GE_EXPR.
(pointer_table::pointer_table): Remove GE_EXPR.
* range-op.h (ge_op1_op2_relation): Delete.

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

index 2f090e752458acb62b4632b6b77518664ae55e99..4faca62c48fa11eb6c3c792848166c675e094ec2 100644 (file)
@@ -1059,32 +1059,10 @@ operator_gt::op2_range (frange &r,
   return true;
 }
 
-class foperator_ge : 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 = TRIO_VARYING) const final override;
-  relation_kind op1_op2_relation (const irange &lhs) const final override
-  {
-    return ge_op1_op2_relation (lhs);
-  }
-  bool op1_range (frange &r, tree type,
-                 const irange &lhs, const frange &op2,
-                 relation_trio = TRIO_VARYING) const final override;
-  bool op2_range (frange &r, tree type,
-                 const irange &lhs, const frange &op1,
-                 relation_trio = TRIO_VARYING) const final override;
-} fop_ge;
-
 bool
-foperator_ge::fold_range (irange &r, tree type,
-                         const frange &op1, const frange &op2,
-                         relation_trio rel) const
+operator_ge::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_GE))
     return true;
@@ -1102,11 +1080,11 @@ foperator_ge::fold_range (irange &r, tree type,
 }
 
 bool
-foperator_ge::op1_range (frange &r,
-                        tree type,
-                        const irange &lhs,
-                        const frange &op2,
-                        relation_trio) const
+operator_ge::op1_range (frange &r,
+                       tree type,
+                       const irange &lhs,
+                       const frange &op2,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -1137,10 +1115,10 @@ foperator_ge::op1_range (frange &r,
 }
 
 bool
-foperator_ge::op2_range (frange &r, tree type,
-                        const irange &lhs,
-                        const frange &op1,
-                        relation_trio) const
+operator_ge::op2_range (frange &r, tree type,
+                       const irange &lhs,
+                       const frange &op1,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -1813,7 +1791,8 @@ public:
       op1_no_nan.clear_nan ();
     if (op2.maybe_isnan ())
       op2_no_nan.clear_nan ();
-    if (!fop_ge.fold_range (r, type, op1_no_nan, op2_no_nan, rel))
+    if (!range_op_handler (GE_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.
@@ -2720,11 +2699,6 @@ float_table::float_table ()
   set (OBJ_TYPE_REF, fop_identity);
   set (REAL_CST, fop_identity);
 
-  // All the relational operators are expected to work, because the
-  // calculation of ranges on outgoing edges expect the handlers to be
-  // present.
-  set (GE_EXPR, fop_ge);
-
   set (ABS_EXPR, fop_abs);
   set (NEGATE_EXPR, fop_negate);
   set (PLUS_EXPR, fop_plus);
index 1c68d54b0851f359d4cb05e7c4aa29a4874ae5e0..d6cd368393278b8b1913c23bb3f83d09860bd793 100644 (file)
@@ -235,4 +235,37 @@ public:
   relation_kind op1_op2_relation (const irange &lhs) const final override;
   void update_bitmask (irange &r, const irange &lh, const irange &rh) const;
 };
+
+class operator_ge :  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 = 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 = 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 = 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 e971bf4cd33c1883ae0f19c21984c28be518553e..a127da22006b94ec45509512fed96de0fa9fa0af 100644 (file)
@@ -67,6 +67,7 @@ operator_not_equal op_not_equal;
 operator_lt op_lt;
 operator_le op_le;
 operator_gt op_gt;
+operator_ge op_ge;
 
 // Invoke the initialization routines for each class of range.
 
@@ -81,6 +82,7 @@ unified_table::unified_table ()
   set (LT_EXPR, op_lt);
   set (LE_EXPR, op_le);
   set (GT_EXPR, op_gt);
+  set (GE_EXPR, op_ge);
 }
 
 // The tables are hidden and accessed via a simple extern function.
@@ -1388,34 +1390,17 @@ operator_gt::op2_range (irange &r, tree type,
 }
 
 
-class operator_ge :  public range_operator
+void
+operator_ge::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, GE_EXPR, lh, rh); }
-} op_ge;
+  update_known_bitmask (r, GE_EXPR, lh, rh);
+}
 
 // Check if the LHS range indicates a relation between OP1 and OP2.
 
 relation_kind
-ge_op1_op2_relation (const irange &lhs)
+operator_ge::op1_op2_relation (const irange &lhs) const
 {
   if (lhs.undefined_p ())
     return VREL_UNDEFINED;
@@ -1430,12 +1415,6 @@ ge_op1_op2_relation (const irange &lhs)
   return VREL_VARYING;
 }
 
-relation_kind
-operator_ge::op1_op2_relation (const irange &lhs) const
-{
-  return ge_op1_op2_relation (lhs);
-}
-
 bool
 operator_ge::fold_range (irange &r, tree type,
                         const irange &op1,
@@ -4783,7 +4762,6 @@ pointer_or_operator::wi_fold (irange &r, tree type,
 \f
 integral_table::integral_table ()
 {
-  set (GE_EXPR, op_ge);
   set (PLUS_EXPR, op_plus);
   set (MINUS_EXPR, op_minus);
   set (MIN_EXPR, op_min);
@@ -4832,7 +4810,6 @@ pointer_table::pointer_table ()
   set (MIN_EXPR, op_ptr_min_max);
   set (MAX_EXPR, op_ptr_min_max);
 
-  set (GE_EXPR, op_ge);
   set (SSA_NAME, op_ident);
   set (INTEGER_CST, op_integer_cst);
   set (ADDR_EXPR, op_addr);
index 411ab5e4a0af1ce731ee211ca00257e58fc8a5dc..20a77e1165e5212a717c94f0f9bbd11720832701 100644 (file)
@@ -265,9 +265,6 @@ extern void wi_set_zero_nonzero_bits (tree type,
                                      wide_int &maybe_nonzero,
                                      wide_int &mustbe_nonzero);
 
-// op1_op2_relation methods that are the same across irange and frange.
-relation_kind ge_op1_op2_relation (const irange &lhs);
-
 // This implements the range operator tables as local objects.
 
 class range_op_table