&& TYPE_PRECISION (TREE_TYPE (@0)) == 1)
(bit_ior @0 (bit_xor @1 { build_one_cst (type); }))))
+/* a | ((~a) ^ b) --> a | (~b) (alt version of the above 2) */
+(simplify
+ (bit_ior:c @0 (bit_xor:cs @1 @2))
+ (with { bool wascmp; }
+ (if (bitwise_inverted_equal_p (@0, @1, wascmp)
+ && (!wascmp || element_precision (type) == 1))
+ (bit_ior @0 (bit_not @2)))))
+
/* (a | b) | (a &^ b) --> a | b */
(for op (bit_and bit_xor)
(simplify
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized-raw" } */
+/* PR tree-optimization/111679 */
+
+int f1(int a, int b)
+{
+ return (~a) | (a ^ b); // ~(a & b) or (~a) | (~b)
+}
+
+_Bool fb(_Bool c, _Bool d)
+{
+ return (!c) | (c ^ d); // ~(c & d) or (~c) | (~d)
+}
+
+_Bool fb1(int x, int y)
+{
+ _Bool a = x == 10, b = y > 100;
+ return (!a) | (a ^ b); // ~(a & b) or (~a) | (~b)
+ // or (x != 10) | (y <= 100)
+}
+
+/* { dg-final { scan-tree-dump-not "bit_xor_expr, " "optimized" } } */
+/* { dg-final { scan-tree-dump-times "bit_not_expr, " 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "bit_and_expr, " 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "ne_expr, _\[0-9\]+, x_\[0-9\]+" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "le_expr, _\[0-9\]+, y_\[0-9\]+" 1 "optimized" } } */