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.
This commit is contained in:
Aldy Hernandez 2024-03-20 09:51:33 +01:00
parent 1a4f5d4991
commit 54d3fd6d9f
2 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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