In order to match evrp behaviour, adjust POINTER_PLUS_EXPR processing to handle a zero constant plus something to return the something.
ie

[0, 0]  + CONST    will now return [CONST, CONST] instead of the previous behaviour of [1, +INF].


Bootstrapped on x86_64-pc-linux-gnu, no regressions, pushed.

Andrew
2020-10-16  Andrew MacLeod  <amacl...@redhat.com>

	* range-op.cc (pointer_plus_operator::wi_fold): Make pointer_plus
	[0, 0] + const return a [const, const] range.


diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6108de367ad..9df08a61289 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3063,6 +3063,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.
   //

Reply via email to