aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2024-03-20 11:15:03 +0100
committerAldy Hernandez <aldyh@redhat.com>2024-05-04 10:25:52 +0200
commitff306c77b7cf5b7b09914f38b7351328835ac4ce (patch)
treec97a111412063ca687484d79db4fdafea29083d1
parent76fae4051a72b2d417d50f1980dff8ab0c50d0c5 (diff)
downloadgcc-ff306c77b7cf5b7b09914f38b7351328835ac4ce.zip
gcc-ff306c77b7cf5b7b09914f38b7351328835ac4ce.tar.gz
gcc-ff306c77b7cf5b7b09914f38b7351328835ac4ce.tar.bz2
Implement operator_ge for prange....
gcc/ChangeLog: * range-op-mixed.h: Add overloaded declarations for pointer variants. * range-op-ptr.cc (operator_ge::fold_range): New. (operator_ge::op1_range): New. (operator_ge::op2_range): New. (operator_ge::op1_op2_relation): New. (operator_ge::pointers_handled_p): New.
-rw-r--r--gcc/range-op-mixed.h12
-rw-r--r--gcc/range-op-ptr.cc108
2 files changed, 120 insertions, 0 deletions
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index f7a07b1..44d51d6 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -372,12 +372,18 @@ public:
const irange &op1, const irange &op2,
relation_trio = TRIO_VARYING) const final override;
bool fold_range (irange &r, tree type,
+ const prange &op1, const prange &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 (prange &r, tree type,
+ const irange &lhs, const prange &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;
@@ -385,12 +391,17 @@ public:
bool op2_range (irange &r, tree type,
const irange &lhs, const irange &op1,
relation_trio = TRIO_VARYING) const final override;
+ bool op2_range (prange &r, tree type,
+ const irange &lhs, const prange &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 irange &,
const irange &) const final override;
+ relation_kind op1_op2_relation (const irange &lhs, const prange &,
+ const prange &) const final override;
relation_kind op1_op2_relation (const irange &lhs, const frange &,
const frange &) const final override;
void update_bitmask (irange &r, const irange &lh,
@@ -398,6 +409,7 @@ public:
// Check op1 and op2 for compatibility.
bool operand_check_p (tree, tree t1, tree t2) const final override
{ return range_compatible_p (t1, t2); }
+ bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override;
};
class operator_identity : public range_operator
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 441a18c..466edc6 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -1853,6 +1853,114 @@ operator_gt::pointers_handled_p (range_op_dispatch_type type,
}
}
+bool
+operator_ge::fold_range (irange &r, tree type,
+ const prange &op1,
+ const prange &op2,
+ relation_trio rel) const
+{
+ if (relop_early_resolve (r, type, op1, op2, rel, VREL_GE))
+ return true;
+
+ signop sign = TYPE_SIGN (op1.type ());
+ gcc_checking_assert (sign == TYPE_SIGN (op2.type ()));
+
+ if (wi::ge_p (op1.lower_bound (), op2.upper_bound (), sign))
+ r = range_true ();
+ else if (!wi::ge_p (op1.upper_bound (), op2.lower_bound (), sign))
+ r = range_false ();
+ else
+ r = range_true_and_false ();
+
+ //update_known_bitmask (r, GE_EXPR, op1, op2);
+ return true;
+}
+
+bool
+operator_ge::op1_range (prange &r, tree type,
+ const irange &lhs,
+ const prange &op2,
+ relation_trio) const
+{
+ if (op2.undefined_p ())
+ return false;
+
+ switch (get_bool_state (r, lhs, type))
+ {
+ case BRS_TRUE:
+ build_ge (r, type, op2);
+ break;
+
+ case BRS_FALSE:
+ build_lt (r, type, op2);
+ break;
+
+ default:
+ break;
+ }
+ return true;
+}
+
+bool
+operator_ge::op2_range (prange &r, tree type,
+ const irange &lhs,
+ const prange &op1,
+ relation_trio) const
+{
+ if (op1.undefined_p ())
+ return false;
+
+ switch (get_bool_state (r, lhs, type))
+ {
+ case BRS_TRUE:
+ build_le (r, type, op1);
+ break;
+
+ case BRS_FALSE:
+ build_gt (r, type, op1);
+ break;
+
+ default:
+ break;
+ }
+ return true;
+}
+
+relation_kind
+operator_ge::op1_op2_relation (const irange &lhs, const prange &,
+ const prange &) const
+{
+ if (lhs.undefined_p ())
+ return VREL_UNDEFINED;
+
+ // FALSE = op1 >= op2 indicates LT_EXPR.
+ if (lhs.zero_p ())
+ return VREL_LT;
+
+ // TRUE = op1 >= op2 indicates GE_EXPR.
+ if (!range_includes_zero_p (lhs))
+ return VREL_GE;
+ return VREL_VARYING;
+}
+
+bool
+operator_ge::pointers_handled_p (range_op_dispatch_type type,
+ unsigned dispatch) const
+{
+ switch (type)
+ {
+ case DISPATCH_FOLD_RANGE:
+ return dispatch == RO_IPP;
+ case DISPATCH_OP1_RANGE:
+ case DISPATCH_OP2_RANGE:
+ return dispatch == RO_PIP;
+ case DISPATCH_OP1_OP2_RELATION:
+ return dispatch == RO_IPP;
+ default:
+ return true;
+ }
+}
+
// Initialize any pointer operators to the primary table
void