https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91504
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Kamlesh Kumar from comment #3) > 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)) > + Looks good. I think there's a related transform already you could put it next to, also it shouldn't be restricted to INTEGER_CST @1? Also the inner bit_and should have :cs if @1 isn't INTEGER_CST. /* (a & ~b) ^ ~a --> ~(a & b) */ (simplify (bit_xor:c (bit_and:cs @0 (bit_not @1)) (bit_not @0)) (bit_not (bit_and @0 @1)))