This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Improve VRP range intersection


I noticed we intersect ~[a_1, a_1] and [2, 2] to ~[a_1, a_1].  While
we don't generally want to choose an integral range a singleton integral
range is always preferable.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 240645)
+++ gcc/tree-vrp.c	(working copy)
@@ -8555,7 +8555,16 @@ intersect_ranges (enum value_range_type
 
   /* 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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]