https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91504
--- Comment #3 from Kamlesh Kumar <kamleshbhalui at gmail dot com> ---
diff --git a/gcc/match.pd b/gcc/match.pd
index 93dcef9..b62ef36 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -137,6 +137,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(pointer_plus integer_zerop @1)
(non_lvalue (convert @1)))
+/* (~value & C) ^ value -> value | C */
+(simplify
+ (bit_xor:c (bit_and (bit_not @0) INTEGER_CST@1) @0)
+ (bit_ior @0 @1))
+
/* ptr - 0 -> (type)ptr */
(simplify
(pointer_diff @0 integer_zerop)
=========================
After above both function produces same asm.
i.e.
foo:
movl %edi, %eax
orb $4, %ah
ret
bar:
movl %edi, %eax
orb $4, %ah
ret