aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2024-03-20 10:23:31 +0100
committerAldy Hernandez <aldyh@redhat.com>2024-05-04 10:25:51 +0200
commite58f14916954411628eb122da996383b8c996b57 (patch)
tree4cd3ed068b56c6846072d0f0fda3e764a05ca1a9
parentf803b93feef60c8c2d4f7f7270bfc94650dbc8f5 (diff)
downloadgcc-e58f14916954411628eb122da996383b8c996b57.zip
gcc-e58f14916954411628eb122da996383b8c996b57.tar.gz
gcc-e58f14916954411628eb122da996383b8c996b57.tar.bz2
Implement operator_bitwise_and for prange.
gcc/ChangeLog: * range-op-mixed.h: Add overloaded declarations for pointer variants. * range-op-ptr.cc (operator_bitwise_and::fold_range): New. (operator_bitwise_and::pointers_handled_p): New.
-rw-r--r--gcc/range-op-mixed.h6
-rw-r--r--gcc/range-op-ptr.cc30
2 files changed, 36 insertions, 0 deletions
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index 0df3007..6158fc5 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -712,10 +712,15 @@ private:
class operator_bitwise_and : public range_operator
{
public:
+ using range_operator::fold_range;
using range_operator::op1_range;
using range_operator::op2_range;
using range_operator::lhs_op1_relation;
using range_operator::update_bitmask;
+ bool fold_range (prange &r, tree type,
+ const prange &op1,
+ const prange &op2,
+ relation_trio) const final override;
bool op1_range (irange &r, tree type,
const irange &lhs, const irange &op2,
relation_trio rel = TRIO_VARYING) const override;
@@ -730,6 +735,7 @@ public:
// Check compatibility of all operands.
bool operand_check_p (tree t1, tree t2, tree t3) const final override
{ return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
+ bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override;
protected:
void wi_fold (irange &r, tree type, const wide_int &lh_lb,
const wide_int &lh_ub, const wide_int &rh_lb,
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index b90b8bb..8d5049b 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -1189,6 +1189,36 @@ operator_addr_expr::pointers_handled_p (range_op_dispatch_type type,
}
}
+bool
+operator_bitwise_and::fold_range (prange &r, tree type,
+ const prange &op1,
+ const prange &op2 ATTRIBUTE_UNUSED,
+ relation_trio) const
+{
+ // For pointer types, we are really only interested in asserting
+ // whether the expression evaluates to non-NULL.
+ if (op1.zero_p () || op2.zero_p ())
+ r.set_zero (type);
+ else
+ r.set_varying (type);
+
+ update_known_bitmask (r, BIT_AND_EXPR, op1, op2);
+ return true;
+}
+
+bool
+operator_bitwise_and::pointers_handled_p (range_op_dispatch_type type,
+ unsigned dispatch) const
+{
+ switch (type)
+ {
+ case DISPATCH_FOLD_RANGE:
+ return dispatch == RO_PPP;
+ default:
+ return true;
+ }
+}
+
// Initialize any pointer operators to the primary table
void