&& tree_to_shwi (@1) < TYPE_PRECISION (TREE_TYPE (@0)))
(eq @0 @2)))
+/* PR110010: (A >> C) != (B >> C) -> (A ^ B) >= (1 << C)
+ and likewise (A >> C) == (B >> C) -> (A ^ B) < (1 << C).
+
+ Note that maybe_canonicalize_comparison_1 related patterns
+ might change ">= (1 << C)" to "> (1 << C - 1)" and
+ "< (1 << C)" to "<= (1 << C - 1)". */
+(for cmp (ne eq)
+ icmp (ge lt)
+ (simplify
+ (cmp (rshift @0 INTEGER_CST@2) (rshift @1 INTEGER_CST@2))
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && TYPE_UNSIGNED (TREE_TYPE (@0))
+ && type_has_mode_precision_p (TREE_TYPE (@0))
+ && types_match (@0, @1)
+ && tree_fits_shwi_p (@2)
+ && tree_to_shwi (@2) > 0
+ && tree_to_shwi (@2) < TYPE_PRECISION (TREE_TYPE (@0)))
+ (icmp (bit_xor @0 @1) (lshift { build_one_cst (TREE_TYPE (@0)); } @2)))))
+
/* Convert ~ (-A) to A - 1. */
(simplify
(bit_not (convert? (negate @0)))
--- /dev/null
+/* { dg-additional-options -O1 } */
+/* { dg-additional-options -fdump-tree-gimple } */
+#define N 5
+
+unsigned f(unsigned a, unsigned b)
+{
+ return (a>>N) != (b>>N);
+}
+
+unsigned f2(unsigned a, unsigned b)
+{
+ return (a>>N) == (b>>N);
+}
+/* { dg-final { scan-tree-dump-times " >> " 0 gimple } } */