value_range_base::operator== was originally lifted from a world where symbolics didn't exist (the ranger branch), but symbolics do exist in mainline.

Although this isn't causing a problem yet, as soon as someone tries to compare non numeric ranges, we'll die. Using operand_equal_p simplifies the comparison code drastically.

I suppose if/when we get multiple sub-ranges in value_range_base, we'll have to adapt this function again to compare things piece wise. For now, let's keep things simple.

OK pending tests?
commit d1177659bd26ac8122410dee092f5ca427b4558b
Author: Aldy Hernandez <al...@redhat.com>
Date:   Mon Nov 4 21:20:26 2019 +0100

    Use operand_equal_p in value_range_base::operator== so we can handle
    symbolics without dying.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6fbbf87e294..3ebe7fd4348 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-04  Aldy Hernandez  <al...@redhat.com>
+
+	* tree-vrp.c (value_range_base::operator==): Use operand_equal_p
+	instead of wide-int's, to properly handle symbolics.
+
 2019-11-04  Aldy Hernandez  <al...@redhat.com>
 
 	* tree-vrp.c (value_range_base::set): Do not special case pointers.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 452895bfc24..e683339f3cd 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -6336,16 +6336,12 @@ value_range_base::operator== (const value_range_base &r) const
   if (undefined_p ())
     return r.undefined_p ();
 
-  if (num_pairs () != r.num_pairs ()
-      || !range_compatible_p (type (), r.type ()))
+  if (!range_compatible_p (type (), r.type ()))
     return false;
 
-  for (unsigned p = 0; p < num_pairs (); p++)
-    if (wi::ne_p (lower_bound (p), r.lower_bound (p))
-	|| wi::ne_p (upper_bound (p), r.upper_bound (p)))
-      return false;
-
-  return true;
+  return (m_kind == r.m_kind
+	  && operand_equal_p (m_min, r.m_min, 0)
+	  && operand_equal_p (m_max, r.m_max, 0));
 }
 
 /* Visit all arguments for PHI node PHI that flow through executable

Reply via email to