https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109986
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:2a3556376c69a1fb588dcf25225950575e42784f commit r14-2751-g2a3556376c69a1fb588dcf25225950575e42784f Author: Drew Ross <drr...@redhat.com> Date: Mon Jul 24 17:51:28 2023 +0200 match.pd: Implement missed optimization (~X | Y) ^ X -> ~(X & Y) [PR109986] Adds a simplification for (~X | Y) ^ X to be folded into ~(X & Y). Also adds the macro bitwise_equal_p for generic and gimple which returns true iff EXPR1 and EXPR2 have the same value. This helps to reduce the number of nop_converts necessary to match the pattern. PR middle-end/109986 gcc/ChangeLog: * generic-match-head.cc (bitwise_equal_p): New macro. * gimple-match-head.cc (bitwise_equal_p): New macro. (gimple_nop_convert): Declare. (gimple_bitwise_equal_p): Helper for bitwise_equal_p. * match.pd ((~X | Y) ^ X -> ~(X & Y)): New simplification. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/pr109986.c: New test. * gcc.dg/tree-ssa/pr109986.c: New test. Co-authored-by: Jakub Jelinek <ja...@redhat.com>