diff mbox

Try harder for conditional evaluation in VRP

Message ID alpine.LSU.2.11.1405271221120.2632@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener May 27, 2014, 10:27 a.m. UTC
Especially for ops with symbolic ranges it may be preferable
to compare one range with an op such as in
[x + 1, x + 1] < x instead of expanding the range of x on
the rhs to sth unrelated.

So, try harder.

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

Richard.

2014-05-27  Richard Biener  <rguenther@suse.de>

	* tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
	Try using literal operands when comparing value-ranges failed.

Comments

Steven Bosscher May 27, 2014, 1:41 p.m. UTC | #1
On Tue, May 27, 2014 at 12:27 PM, Richard Biener wrote:
>         * tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
>         Try using literal operands when comparing value-ranges failed.

No test case?

Ciao!
Steven
Richard Biener May 27, 2014, 1:45 p.m. UTC | #2
On Tue, 27 May 2014, Steven Bosscher wrote:

> On Tue, May 27, 2014 at 12:27 PM, Richard Biener wrote:
> >         * tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
> >         Try using literal operands when comparing value-ranges failed.
> 
> No test case?

Sorry ;)  Happens to patches I uncover in my dev tree.  I'll try
to come up with sth (I remember coding it when workin on some
PR ... but I've lost track of which one).

Richard.
diff mbox

Patch

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 210931)
+++ gcc/tree-vrp.c	(working copy)
@@ -6919,14 +6919,15 @@  vrp_evaluate_conditional_warnv_with_ops_
   vr0 = (TREE_CODE (op0) == SSA_NAME) ? get_value_range (op0) : NULL;
   vr1 = (TREE_CODE (op1) == SSA_NAME) ? get_value_range (op1) : NULL;
 
+  tree res = NULL_TREE;
   if (vr0 && vr1)
-    return compare_ranges (code, vr0, vr1, strict_overflow_p);
-  else if (vr0 && vr1 == NULL)
-    return compare_range_with_value (code, vr0, op1, strict_overflow_p);
-  else if (vr0 == NULL && vr1)
-    return (compare_range_with_value
+    res = compare_ranges (code, vr0, vr1, strict_overflow_p);
+  if (!res && vr0)
+    res = compare_range_with_value (code, vr0, op1, strict_overflow_p);
+  if (!res && vr1)
+    res = (compare_range_with_value
 	    (swap_tree_comparison (code), vr1, op0, strict_overflow_p));
-  return NULL;
+  return res;
 }
 
 /* Helper function for vrp_evaluate_conditional_warnv. */