aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2020-10-16 15:10:17 -0400
committerAndrew MacLeod <amacleod@redhat.com>2020-10-16 15:10:17 -0400
commit58492575a118fd14c8184823467c815347cde219 (patch)
treea0d86017b5ec5b4c005df9613be51a5ee5a2d84b /gcc
parentaabc96c9195892e669b7728b0e00a7c1a6f3d161 (diff)
downloadgcc-58492575a118fd14c8184823467c815347cde219.zip
gcc-58492575a118fd14c8184823467c815347cde219.tar.gz
gcc-58492575a118fd14c8184823467c815347cde219.tar.bz2
pointer_plus [0, 0] + const folding
Return a constant range if POINTER_PLUS is [0,0] plus a const. * range-op.cc (pointer_plus_operator::wi_fold): Make pointer_plus [0, 0] + const return a [const, const] range.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/range-op.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index de4cfe4..0efa001 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3064,6 +3064,14 @@ pointer_plus_operator::wi_fold (irange &r, tree type,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
+ // Check for [0,0] + const, and simply return the const.
+ if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub)
+ {
+ tree val = wide_int_to_tree (type, rh_lb);
+ r.set (val, val);
+ return;
+ }
+
// For pointer types, we are really only interested in asserting
// whether the expression evaluates to non-NULL.
//