https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110922
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I think you need the following 3 patterns, there might be more though: (simplify (bit_and:c (bit_and:c (eq:c @0 @1) (eq:c @0 @2) ) (ne:c @1 @2) ) ( { falsevalue; } ) ) (simplify (bit_and:c (bit_and:c (eq:c @0 @1) (ne:c @1 @2) ) (eq:c @0 @2) ) ( { falsevalue; } ) ) (simplify (bit_and:c (eq:c @0 @1) (bit_and:c (ne:c @1 @2) (eq:c @0 @2) ) ) ( { falsevalue; } ) )