diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-08-17 11:13:14 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-08-17 13:38:50 -0400 |
commit | dc48d1d1d4458773f89f21b2f019f66ddf88f2e5 (patch) | |
tree | 5ee57f4e1f2fc33b88839811652935abf7a9c6bb /gcc/range-op.cc | |
parent | d7b6cad9d6c40f1dab907abd8e71e713bb2a5bf5 (diff) | |
download | gcc-dc48d1d1d4458773f89f21b2f019f66ddf88f2e5.zip gcc-dc48d1d1d4458773f89f21b2f019f66ddf88f2e5.tar.gz gcc-dc48d1d1d4458773f89f21b2f019f66ddf88f2e5.tar.bz2 |
Fix range-ops operator_addr.
Lack of symbolic information prevents op1_range from beig able to draw
the same conclusions as fold_range can.
PR tree-optimization/111009
gcc/
* range-op.cc (operator_addr_expr::op1_range): Be more restrictive.
gcc/testsuite/
* gcc.dg/pr111009.c: New.
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r-- | gcc/range-op.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 086c6c1..268f6b6 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -4325,7 +4325,17 @@ operator_addr_expr::op1_range (irange &r, tree type, const irange &op2, relation_trio) const { - return operator_addr_expr::fold_range (r, type, lhs, op2); + 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 (!contains_zero_p (lhs) && TYPE_OVERFLOW_UNDEFINED (type)) + r = range_nonzero (type); + else + r.set_varying (type); + return true; } // Initialize any integral operators to the primary table |