On Tue, 2 Feb 2016, Richard Biener wrote:

*** gcc/match.pd        (revision 233067)
--- gcc/match.pd        (working copy)
*************** DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
*** 2094,2099 ****
--- 2094,2117 ----
  (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1))
  @2)

+ /* Simple range test simplifications.  */
+ /* A < B || A >= B -> true.  */
+ (for test1 (lt le ne)
+      test2 (ge gt eq)
+  (simplify
+   (bit_ior:c (test1 @0 @1) (test2 @0 @1))
+   (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+        || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0)))
+    { constant_boolean_node (true, type); })))
+ /* A < B && A >= B -> false.  */
+ (for test1 (lt lt lt le ne eq)
+      test2 (ge gt eq gt eq gt)

The lack of symmetry between the || and && cases is surprising. Is there any reason not to handle the pairs le/ge, le/ne and ge/ne for bit_ior?

+  (simplify
+   (bit_and:c (test1 @0 @1) (test2 @0 @1))
+   (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+        || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0)))
+    { constant_boolean_node (false, type); })))
+
 /* -A CMP -B -> B CMP A.  */
 (for cmp (tcc_comparison)
      scmp (swapped_tcc_comparison)

--
Marc Glisse

Reply via email to