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 COMMITTED: Fix tree-vrp bug, PR 31034


This patch fixes a bug in my recent tree-vrp.c changes, reported as PR
31034.  The bug was in the handling of code like ASSERT_EXPR (i > 0)
when the lower limit was an overflow infinity.

Bootstrapped and tested on i686-pc-linux-gnu.  Committed.

Ian


2007-03-05  Ian Lance Taylor  <iant@google.com>

	PR tree-optimization/31034
	* tree-vrp.c (extract_range_from_assert): Don't try to handle a
	half-range if the other side is an overflow infinity.


Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 122538)
+++ gcc/tree-vrp.c	(working copy)
@@ -1137,13 +1137,14 @@ extract_range_from_assert (value_range_t
       /* If the maximum value forces us to be out of bounds, simply punt.
 	 It would be pointless to try and do anything more since this
 	 all should be optimized away above us.  */
-      if (cond_code == LT_EXPR && compare_values (max, min) == 0)
+      if ((cond_code == LT_EXPR
+	   && compare_values (max, min) == 0)
+	  || is_overflow_infinity (max))
 	set_value_range_to_varying (vr_p);
       else
 	{
 	  /* For LT_EXPR, we create the range [MIN, MAX - 1].  */
-	  if (cond_code == LT_EXPR
-	      && !is_positive_overflow_infinity (max))
+	  if (cond_code == LT_EXPR)
 	    {
 	      tree one = build_int_cst (type, 1);
 	      max = fold_build2 (MINUS_EXPR, type, max, one);
@@ -1169,13 +1170,14 @@ extract_range_from_assert (value_range_t
       /* If the minimum value forces us to be out of bounds, simply punt.
 	 It would be pointless to try and do anything more since this
 	 all should be optimized away above us.  */
-      if (cond_code == GT_EXPR && compare_values (min, max) == 0)
+      if ((cond_code == GT_EXPR
+	   && compare_values (min, max) == 0)
+	  || is_overflow_infinity (min))
 	set_value_range_to_varying (vr_p);
       else
 	{
 	  /* For GT_EXPR, we create the range [MIN + 1, MAX].  */
-	  if (cond_code == GT_EXPR
-	      && !is_negative_overflow_infinity (min))
+	  if (cond_code == GT_EXPR)
 	    {
 	      tree one = build_int_cst (type, 1);
 	      min = fold_build2 (PLUS_EXPR, type, min, one);


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