While working on PR126085, i keep running into this problem:

‘gimple_match_range_of_expr’ was not declared in this scope.
This is giving me headache, what is the problem since I can't figure it out?

git diff:

diff --git a/gcc/match.pd b/gcc/match.pd
index 7da15cc4cdc..2caf9139a39 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3804,10 +3804,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        (if (rescode == rcmp)
         (rcmp @0 @1)))))))))

-/* (type)([0,1]@a != 0) -> (type)a
-   (type)([0,1]@a == 1) -> (type)a
-   (type)([0,1]@a == 0) -> a ^ 1
-   (type)([0,1]@a != 1) -> a ^ 1.  */
+/* (type)([CST,CST + 1]@a != CST) -> (type)(a - CST)
+   (type)([CST - 1,CST]@a == CST) -> (type)(a - (CST - 1))
+   (type)([CST,CST + 1]@a == CST) -> (a - CST) ^ 1
+   (type)([CST - 1,CST]@a != CST) -> (a - (CST - 1)) ^ 1.  */
 (for eqne (eq ne)
  (simplify
   (convert (eqne zero_one_valued_p@0 INTEGER_CST@1))
@@ -3819,6 +3819,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        there is no type change. */
     (if (types_match (type, TREE_TYPE (@0)))
      (bit_xor @0 { build_one_cst (type); } ))))))
+#ifdef GIMPLE
+(for eqne (eq ne)
+ (simplify
+  (convert (eqne @0 INTEGER_CST@1))
+  (with {
+    int_range_max vr0;
+    int cond = 0;
+    if (gimple_match_range_of_expr (vr0, @0))
+      cond = 1;
+  }
+  (if (cond == 2)
+    @0
+  )
+  )
+)
+)
+#endif

 /* ((a ^ b) & c) cmp d || a != b --> (0 cmp d || a != b). */
 (for cmp (simple_comparison)

Reply via email to