tree-vrp.c (extract_range_from_binary_expr_1): Normalize VR_VARYING for PLUS/MINUS_EXPR.
authorAldy Hernandez <aldyh@redhat.com>
Fri, 14 Sep 2018 10:46:35 +0000 (10:46 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Fri, 14 Sep 2018 10:46:35 +0000 (10:46 +0000)
* tree-vrp.c (extract_range_from_binary_expr_1): Normalize
VR_VARYING for PLUS/MINUS_EXPR.

From-SVN: r264307

gcc/ChangeLog
gcc/tree-vrp.c

index 02b128e24869e4f535b4f1aa1fd565f877817f50..b5fb359c768041b11064f7d50549df96cb0e7306 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-14  Aldy Hernandez  <aldyh@redhat.com>
+
+       * tree-vrp.c (extract_range_from_binary_expr_1): Normalize
+       VR_VARYING for PLUS/MINUS_EXPR.
+
 2018-09-14  Ilya Leoshkevich  <iii@linux.ibm.com>
 
        * config/s390/s390-passes.def (INSERT_PASS_BEFORE): Improve
index d26011a9e66394456cd45ae88f5ff54d6a0c46d1..1adb919a6dfdea20fe4e3043573b60cc4d8dca9c 100644 (file)
@@ -1415,6 +1415,22 @@ extract_range_from_binary_expr_1 (value_range *vr,
      range and see what we end up with.  */
   if (code == PLUS_EXPR || code == MINUS_EXPR)
     {
+      /* This will normalize things such that calculating
+        [0,0] - VR_VARYING is not dropped to varying, but is
+        calculated as [MIN+1, MAX].  */
+      if (vr0.type == VR_VARYING)
+       {
+         vr0.type = VR_RANGE;
+         vr0.min = vrp_val_min (expr_type);
+         vr0.max = vrp_val_max (expr_type);
+       }
+      if (vr1.type == VR_VARYING)
+       {
+         vr1.type = VR_RANGE;
+         vr1.min = vrp_val_min (expr_type);
+         vr1.max = vrp_val_max (expr_type);
+       }
+
       const bool minus_p = (code == MINUS_EXPR);
       tree min_op0 = vr0.min;
       tree min_op1 = minus_p ? vr1.max : vr1.min;