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;
}
(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>
--- /dev/null
+/* { 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" } } */