https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111432
--- Comment #3 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:b18d1cabe2f9cccc0cad697e1e0bfd2abebb85f9 commit r14-4686-gb18d1cabe2f9cccc0cad697e1e0bfd2abebb85f9 Author: Andrew Pinski <pins...@gmail.com> Date: Fri Oct 13 13:27:18 2023 -0700 MATCH: [PR111432] Simplify `a & (x | CST)` to a when we know that (a & ~CST) == 0 This adds the simplification `a & (x | CST)` to a when we know that `(a & ~CST) == 0`. In a similar fashion as `a & CST` is handle. I looked into handling `a | (x & CST)` but that I don't see any decent simplifications happening. OK? Bootstrapped and tested on x86_linux-gnu with no regressions. PR tree-optimization/111432 gcc/ChangeLog: * match.pd (`a & (x | CST)`): New pattern. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bitops-7.c: New test.