All this nonsense:

-      rtype = get_range_info (t, &min, &max);
-      if (rtype == VR_RANGE)
-       {
-         if (wi::lt_p (max, w, TYPE_SIGN (TREE_TYPE (t))))
-           return true;
-         if (wi::lt_p (w, min, TYPE_SIGN (TREE_TYPE (t))))
-           return true;
-       }
-      else if (rtype == VR_ANTI_RANGE
-              && wi::le_p (min, w, TYPE_SIGN (TREE_TYPE (t)))
-              && wi::le_p (w, max, TYPE_SIGN (TREE_TYPE (t))))

Replaced by an API like Kutulu intended.

+      get_range_info (t, vr);
+      if (!vr.may_contain_p (wide_int_to_tree (TREE_TYPE (t), w)))

Ain't it grand?

OK for trunk, depending on get_range_info changes of course?

Aldy
commit 3a3fa7eb1baba60d17b4b7731972951173c5d615
Author: Aldy Hernandez <al...@redhat.com>
Date:   Thu Nov 8 13:04:59 2018 +0100

            * fold-const.c (expr_not_equal_to): Use value_range API.

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 5399288dfc5..744f946fa15 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9255,8 +9255,7 @@ tree_expr_nonzero_p (tree t)
 bool
 expr_not_equal_to (tree t, const wide_int &w)
 {
-  wide_int min, max, nz;
-  value_range_kind rtype;
+  value_range vr;
   switch (TREE_CODE (t))
     {
     case INTEGER_CST:
@@ -9265,17 +9264,8 @@ expr_not_equal_to (tree t, const wide_int &w)
     case SSA_NAME:
       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
 	return false;
-      rtype = get_range_info (t, &min, &max);
-      if (rtype == VR_RANGE)
-	{
-	  if (wi::lt_p (max, w, TYPE_SIGN (TREE_TYPE (t))))
-	    return true;
-	  if (wi::lt_p (w, min, TYPE_SIGN (TREE_TYPE (t))))
-	    return true;
-	}
-      else if (rtype == VR_ANTI_RANGE
-	       && wi::le_p (min, w, TYPE_SIGN (TREE_TYPE (t)))
-	       && wi::le_p (w, max, TYPE_SIGN (TREE_TYPE (t))))
+      get_range_info (t, vr);
+      if (!vr.may_contain_p (wide_int_to_tree (TREE_TYPE (t), w)))
 	return true;
       /* If T has some known zero bits and W has any of those bits set,
 	 then T is known not to be equal to W.  */

Reply via email to