On 11/5/19 3:55 AM, Andrew MacLeod wrote:
On 11/4/19 6:05 PM, Aldy Hernandez wrote:


On 11/4/19 11:45 PM, Andrew MacLeod wrote:
On 11/4/19 5:23 PM, Aldy Hernandez wrote:
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?
Oh, we brought over the multiple sub-range bits to value_range_base... yeah we can remove that and just check for operand equality.  we'll deal with multiple subranges when thats a thing.


Is this any different than just calling value_range_base::equal_p()?

Ooops, indeed, that's the same thing.

Adjusted.

OK pending tests?
yeah, approved.

Final committed patch attached. I had to remove the now unused range_compatible_p function, as it's no longer necessary.

Thanks.

commit 10eefa1934bb1833c85d1c445f4da01b933c0909
Author: Aldy Hernandez <al...@redhat.com>
Date:   Mon Nov 4 21:20:26 2019 +0100

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

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e726ff6d0a0..1c2fff16295 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-05  Aldy Hernandez  <al...@redhat.com>
+
+	* tree-vrp.c (value_range_base::operator==): Use equal_p to
+	properly handle symbolics.
+	(range_compatible_p): Remove.
+
 2019-11-04  Kamlesh Kumar  <kamleshbha...@gmail.com>
 
 	* common.opt (-fabi-version): Document =14.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 452895bfc24..a6d44e9dc6d 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -6319,33 +6319,10 @@ value_range_base::intersect (const value_range_base &r)
     dump_flags |= TDF_DETAILS;
 }
 
-/* Return TRUE if two types are compatible for range operations.  */
-
-static bool
-range_compatible_p (tree t1, tree t2)
-{
-  if (POINTER_TYPE_P (t1) && POINTER_TYPE_P (t2))
-    return true;
-
-  return types_compatible_p (t1, t2);
-}
-
 bool
 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 ()))
-    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 equal_p (r);
 }
 
 /* Visit all arguments for PHI node PHI that flow through executable

Reply via email to