]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add a hybrid MIN_EXPR operator for integer and pointer.
authorAndrew MacLeod <amacleod@redhat.com>
Sat, 10 Jun 2023 20:34:26 +0000 (16:34 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 12 Jun 2023 14:48:40 +0000 (10:48 -0400)
This adds an operator to the unified table for MIN_EXPR which will
select either the pointer or integer version based on the type passed
to the method.   This is for use until we have a seperate PRANGE class.

* range-op-mixed.h (operator_min): Remove final.
* range-op-ptr.cc (pointer_table::pointer_table): Remove MIN_EXPR.
(class hybrid_min_operator): New.
(range_op_table::initialize_pointer_ops): Add hybrid_min_operator.
* range-op.cc (unified_table::unified_table): Comment out MIN_EXPR.

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

index e4852e974c4974fb93cc186c9a4b543847bd0da7..a65935435c27008f816f287dc24e22285a6c7cce 100644 (file)
@@ -625,11 +625,11 @@ class operator_min : public range_operator
 {
 public:
   void update_bitmask (irange &r, const irange &lh,
-                      const irange &rh) const final override;
-private:
+                      const irange &rh) const override;
+protected:
   void wi_fold (irange &r, tree type, const wide_int &lh_lb,
                const wide_int &lh_ub, const wide_int &rh_lb,
-               const wide_int &rh_ub) const final override;
+               const wide_int &rh_ub) const override;
 };
 
 class operator_max : public range_operator
index 7b22d0bf05b3c1e104736f43e10c2465c9d418da..483e43ca994622c85a813ca054a224a959b71b5b 100644 (file)
@@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type,
 
 pointer_table::pointer_table ()
 {
-  set (MIN_EXPR, op_ptr_min_max);
   set (MAX_EXPR, op_ptr_min_max);
 }
 
@@ -380,6 +379,32 @@ public:
     }
 } op_hybrid_or;
 
+// Temporary class which dispatches routines to either the INT version or
+// the pointer version depending on the type.  Once PRANGE is a range
+// class, we can remove the hybrid.
+
+class hybrid_min_operator : public operator_min
+{
+public:
+  void update_bitmask (irange &r, const irange &lh,
+                      const irange &rh) const final override
+    {
+      if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ()))
+       operator_min::update_bitmask (r, lh, rh);
+    }
+
+  void wi_fold (irange &r, tree type, const wide_int &lh_lb,
+               const wide_int &lh_ub, const wide_int &rh_lb,
+               const wide_int &rh_ub) const final override
+    {
+      if (INTEGRAL_TYPE_P (type))
+       return operator_min::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+      else
+       return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+    }
+} op_hybrid_min;
+
+
 
 
 // Initialize any pointer operators to the primary table
@@ -391,4 +416,5 @@ range_op_table::initialize_pointer_ops ()
   set (POINTER_DIFF_EXPR, op_pointer_diff);
   set (BIT_AND_EXPR, op_hybrid_and);
   set (BIT_IOR_EXPR, op_hybrid_or);
+  set (MIN_EXPR, op_hybrid_min);
 }
index 0a9a3297de7e99cd10db0642f44b3d388f09d67c..481f3b1324d8eb336c1cdfcd6eaf2e59e4d76cc1 100644 (file)
@@ -123,7 +123,7 @@ unified_table::unified_table ()
 
   // set (BIT_AND_EXPR, op_bitwise_and);
   // set (BIT_IOR_EXPR, op_bitwise_or);
-  set (MIN_EXPR, op_min);
+  // set (MIN_EXPR, op_min);
   set (MAX_EXPR, op_max);
 }