aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2024-10-23 10:59:13 -0400
committerAndrew MacLeod <amacleod@redhat.com>2024-10-24 08:49:29 -0400
commitf24e10876689dcd92b05756bd3ec833ddf1e6b7e (patch)
tree41cb2bde67b2a5db158af27f34476b9c8d1edc6b
parentf9d94c1d5cf051350a39a9816f35cf94d351f6da (diff)
downloadgcc-f24e10876689dcd92b05756bd3ec833ddf1e6b7e.zip
gcc-f24e10876689dcd92b05756bd3ec833ddf1e6b7e.tar.gz
gcc-f24e10876689dcd92b05756bd3ec833ddf1e6b7e.tar.bz2
Implement pointer_or_operator.
The class pointer_or is no longer used, and can be removed. Its functionality was never moved to the new dispatch system. This implements operator_bitwise_or::fold_range() for prange operands. * range-op-mixed.h (operator_bitwise_or::fold_range): Add prange variant. * range-op-ptr.cc (class pointer_or_operator): Remove. (pointer_or_operator::op1_range): Remove. (pointer_or_operator::op2_range): Remove. (pointer_or_operator::wi_fold): Remove. (operator_bitwise_or::fold_range): New prange variant.
-rw-r--r--gcc/range-op-mixed.h6
-rw-r--r--gcc/range-op-ptr.cc63
2 files changed, 16 insertions, 53 deletions
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index cc1db2f..f7c447d 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -809,9 +809,15 @@ protected:
class operator_bitwise_or : public range_operator
{
public:
+ using range_operator::fold_range;
using range_operator::op1_range;
using range_operator::op2_range;
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;
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index dd312a8..ef2b2cc 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -379,69 +379,26 @@ pointer_plus_operator::op2_range (irange &r, tree type,
return true;
}
-
-class pointer_or_operator : public range_operator
-{
-public:
- using range_operator::op1_range;
- using range_operator::op2_range;
- virtual bool op1_range (irange &r, tree type,
- const irange &lhs,
- const irange &op2,
- relation_trio rel = TRIO_VARYING) const;
- virtual bool op2_range (irange &r, tree type,
- const irange &lhs,
- const irange &op1,
- relation_trio rel = TRIO_VARYING) const;
- virtual 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;
-} op_pointer_or;
-
-bool
-pointer_or_operator::op1_range (irange &r, tree type,
- const irange &lhs,
- const irange &op2 ATTRIBUTE_UNUSED,
- relation_trio) const
-{
- if (lhs.undefined_p ())
- return false;
- if (lhs.zero_p ())
- {
- r.set_zero (type);
- return true;
- }
- r.set_varying (type);
- return true;
-}
-
bool
-pointer_or_operator::op2_range (irange &r, tree type,
- const irange &lhs,
- const irange &op1,
- relation_trio) const
-{
- return pointer_or_operator::op1_range (r, type, lhs, op1);
-}
-
-void
-pointer_or_operator::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
+operator_bitwise_or::fold_range (prange &r, tree type,
+ const prange &op1,
+ const prange &op2,
+ relation_trio) const
{
// For pointer types, we are really only interested in asserting
// whether the expression evaluates to non-NULL.
- if (!wi_includes_zero_p (type, lh_lb, lh_ub)
- && !wi_includes_zero_p (type, rh_lb, rh_ub))
+ if (!op1.zero_p () || !op2.zero_p ())
r.set_nonzero (type);
- else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
+ else if (op1.zero_p () && op2.zero_p ())
r.set_zero (type);
else
r.set_varying (type);
+
+ update_known_bitmask (r, BIT_IOR_EXPR, op1, op2);
+ return true;
}
+
class operator_pointer_diff : public range_operator
{
using range_operator::fold_range;