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] Make compare_ranges smarter


 Hi,

  This patch makes compare_ranges return false for
[V0_MIN, V0_MAX] == [V1_MIN, V1_MAX] if V0_MAX < V1_MIN or V1_MAX < V0_MIN.

 This has been bootstrapped and regtested on ia64-linux with no new
regressions.  Ok for mainline?


-- 
Thanks,
Jim

http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim

2005-08-02  James A. Morrison  <phython@gcc.gnu.org>

	* tree-vrp.c (compare_ranges): Return false for EQ_EXPR if VR0 is less
	than VR1 or vice-versa.

Index: tree-vrp.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-vrp.c,v
retrieving revision 2.47
diff -u -p -r2.47 tree-vrp.c
--- tree-vrp.c	29 Jul 2005 15:21:54 -0000	2.47
+++ tree-vrp.c	30 Jul 2005 18:10:26 -0000
@@ -1677,6 +1710,10 @@ compare_ranges (enum tree_code comp, val
 	  else if (cmp_min != -2 && cmp_max != -2)
 	    return boolean_false_node;
 	}
+      /* If [V0_MIN, V1_MAX] < [V1_MIN, V1_MAX] then V0 != V1.  */
+      else if (compare_values (vr0->min, vr1->max) == 1
+	       || compare_values (vr1->min, vr0->max) == 1)
+	return boolean_false_node;
 
       return NULL_TREE;
     }
/* { dg-do compile } */
/* { dg-options "-O1 -ftree-vrp -fdump-tree-vrp" } */

extern void link_error ();

void test02(unsigned int a, unsigned int b)
{
  unsigned int x = 0x80000000;
  if (a > x)
    if (b < x)
      if (a == b)
        link_error ();
}

/* { dg-final { scan-tree-dump-times "link_error" 0 "vrp" } } */
/* { dg-final { cleanup-tree-dump "vrp" } } */

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