diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
index bcc2d636861c3daf95654512c91d847164d0c8e4..5f8a1a1ad8e3ebc30ff06b91c69fe5c2e92a68c6 100644
--- a/gcc/gimple-match-head.cc
+++ b/gcc/gimple-match-head.cc
@@ -333,9 +333,23 @@ gimple_bitwise_inverted_equal_p (tree expr1, tree expr2, bool &wascmp, tree (*va
   if (!operand_equal_p (op11, op21))
     return false;
   wascmp = true;
-  if (invert_tree_comparison (gimple_assign_rhs_code (a1),
-			      HONOR_NANS (op10))
-	== gimple_assign_rhs_code (a2))
+  tree_code ac1 = gimple_assign_rhs_code (a1);
+  tree_code ac2 = gimple_assign_rhs_code (a2);
+  /* Match `^` against `==` but this should only
+     happen when the type is a 1bit precision integer.  */
+  if (ac1 == BIT_XOR_EXPR)
+    {
+      tree type = TREE_TYPE (newexpr1);
+      gcc_assert (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) == 1);
+      return ac2 == EQ_EXPR;
+    }
+  if (ac2 == BIT_XOR_EXPR)
+    {
+      tree type = TREE_TYPE (newexpr1);
+      gcc_assert (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) == 1);
+      return ac1 == EQ_EXPR;
+    }
+  if (invert_tree_comparison (ac1, HONOR_NANS (op10)) == ac2)
     return true;
   return false;
 }
diff --git a/gcc/match.pd b/gcc/match.pd
index 87e2fab81f7174bb48717d65991e05777ac11502..7b4b15acc412935ea86756720f6f6605a32b171f 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -182,6 +182,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (convert (cmp@0 @1 @2))
    (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))))
 )
+/* `a ^ b` is another form of `a != b` when the type
+    is a 1bit precission integer.  */
+(match (maybe_cmp @0)
+ (bit_xor@0 @1 @2)
+ (if (INTEGRAL_TYPE_P (type)
+      && TYPE_PRECISION (type) == 1)))
 #endif
 
 /* Transform likes of (char) ABS_EXPR <(int) x> into (char) ABSU_EXPR <x>
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bitops-bool-1.c b/gcc/testsuite/gcc.dg/tree-ssa/bitops-bool-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..8b43afb5d66097f578f7734c40f0f01fde24ee38
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/bitops-bool-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-forwprop1" } */
+/* PR tree-optimized/113186 */
+
+_Bool f(_Bool a, _Bool c)
+{
+  _Bool b = (a^c);
+  _Bool d = (a^!c);
+  return b & d;
+}
+
+/* This function should be optimized to return 0; */
+/* { dg-final { scan-tree-dump "return 0" "optimized" } } */
+/* { dg-final { scan-tree-dump "return 0" "forwprop1" } } */