aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2024-03-20 09:51:33 +0100
committerAldy Hernandez <aldyh@redhat.com>2024-05-04 10:25:51 +0200
commit54d3fd6d9f5d029c23ab376df2f5decb4902907d (patch)
tree022e7d5c454c4a300d3abb54ffef999f90116869
parent1a4f5d499109d3f2a06bfd1403b6d47d6f55e481 (diff)
downloadgcc-54d3fd6d9f5d029c23ab376df2f5decb4902907d.zip
gcc-54d3fd6d9f5d029c23ab376df2f5decb4902907d.tar.gz
gcc-54d3fd6d9f5d029c23ab376df2f5decb4902907d.tar.bz2
Implement operator_addr_expr for prange.
gcc/ChangeLog: * range-op-mixed.h: Add overloaded declarations for pointer variants. * range-op-ptr.cc (operator_addr_expr::op1_range): New. (operator_addr_expr::pointers_handled_p): New.
-rw-r--r--gcc/range-op-mixed.h4
-rw-r--r--gcc/range-op-ptr.cc38
2 files changed, 42 insertions, 0 deletions
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index b69e674..0df3007 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -655,6 +655,10 @@ public:
bool op1_range (irange &r, tree type,
const irange &lhs, const irange &op2,
relation_trio rel = TRIO_VARYING) const final override;
+ bool op1_range (prange &r, tree type,
+ const prange &lhs, const prange &op2,
+ relation_trio rel = TRIO_VARYING) const final override;
+ bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override;
};
class operator_bitwise_not : public range_operator
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 0addd10..38d9f65 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -1021,6 +1021,44 @@ operator_max::pointers_handled_p (range_op_dispatch_type type,
}
}
+bool
+operator_addr_expr::op1_range (prange &r, tree type,
+ const prange &lhs,
+ const prange &op2,
+ relation_trio) const
+{
+ if (empty_range_varying (r, type, lhs, op2))
+ return true;
+
+ // Return a non-null pointer of the LHS type (passed in op2), but only
+ // if we cant overflow, eitherwise a no-zero offset could wrap to zero.
+ // See PR 111009.
+ if (!lhs.undefined_p ()
+ && !range_includes_zero_p (lhs)
+ && TYPE_OVERFLOW_UNDEFINED (type))
+ r.set_nonzero (type);
+ else
+ r.set_varying (type);
+ return true;
+}
+
+bool
+operator_addr_expr::pointers_handled_p (range_op_dispatch_type type,
+ unsigned dispatch) const
+{
+ switch (type)
+ {
+ case DISPATCH_FOLD_RANGE:
+ // NOTE: It looks like we never generate this combination.
+ gcc_unreachable ();
+ return false;
+ case DISPATCH_OP1_RANGE:
+ return dispatch == RO_PPP;
+ default:
+ return true;
+ }
+}
+
// Initialize any pointer operators to the primary table
void