https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111282
--- Comment #6 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:e8d418df3dc609f27487deece796d4aa69004b8c commit r14-4561-ge8d418df3dc609f27487deece796d4aa69004b8c Author: Andrew Pinski <pins...@gmail.com> Date: Tue Oct 10 12:45:56 2023 -0700 MATCH: [PR111282] Simplify `a & (b ^ ~a)` to `a & b` While `a & (b ^ ~a)` is optimized to `a & b` on the rtl level, it is always good to optimize this at the gimple level and allows us to match a few extra things including where a is a comparison. Note I had to update/change the testcase and-1.c to avoid matching this case as we can match -2 and 1 as bitwise inversions. PR tree-optimization/111282 gcc/ChangeLog: * match.pd (`a & ~(a ^ b)`, `a & (a == b)`, `a & ((~a) ^ b)`): New patterns. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/and-1.c: Update testcase to avoid matching `~1 & (a ^ 1)` simplification. * gcc.dg/tree-ssa/bitops-6.c: New test.