tree-vrp.c (intersect_ranges): If we failed to handle the intersection choose a const...
authorRichard Biener <rguenther@suse.de>
Fri, 30 Sep 2016 07:09:28 +0000 (07:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 30 Sep 2016 07:09:28 +0000 (07:09 +0000)
2016-09-30  Richard Biener  <rguenther@suse.de>

* tree-vrp.c (intersect_ranges): If we failed to handle
the intersection choose a constant singleton range if available.

From-SVN: r240647

gcc/ChangeLog
gcc/tree-vrp.c

index d0a4199be3bf6c8f4192c3c8128765c98b19c3ff..25129cb5d964e495c6749ba5ddec911d6da0b376 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-30  Richard Biener  <rguenther@suse.de>
+
+       * tree-vrp.c (intersect_ranges): If we failed to handle
+       the intersection choose a constant singleton range if available.
+
 2016-09-30  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77399
index dbff92f69ea8e9ca25d90b48019812aa4da0140d..7a08be7b2aa8340b71e4ac89bfb1fe14a9b9892e 100644 (file)
@@ -8555,7 +8555,16 @@ intersect_ranges (enum value_range_type *vr0type,
 
   /* As a fallback simply use { *VRTYPE, *VR0MIN, *VR0MAX } as
      result for the intersection.  That's always a conservative
-     correct estimate.  */
+     correct estimate unless VR1 is a constant singleton range
+     in which case we choose that.  */
+  if (vr1type == VR_RANGE
+      && is_gimple_min_invariant (vr1min)
+      && vrp_operand_equal_p (vr1min, vr1max))
+    {
+      *vr0type = vr1type;
+      *vr0min = vr1min;
+      *vr0max = vr1max;
+    }
 
   return;
 }