https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:1bf0cd05cb30889cae4b6cf06e80b7f3a13c40c1 commit r14-4241-g1bf0cd05cb30889cae4b6cf06e80b7f3a13c40c1 Author: Andrew Pinski <apin...@marvell.com> Date: Sat Sep 23 04:38:02 2023 +0000 MATCH: Add `(X & ~Y) & Y` and `(X | ~Y) | Y` Even though this gets optimized by reassociation, catching it more often will always be better. Note the reason why I didn't add `(X ^ ~Y) ^ Y` is that it gets caught by prefering `~(X ^ Y)` to `(X ^ ~Y)` which then it is caught by the the pattern for `(X ^ Y) ^ Y` already. PR tree-optimization/111543 gcc/ChangeLog: * match.pd (`(X & ~Y) & Y`, `(X | ~Y) | Y`): New patterns. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bitops-4.c: New test.