https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106164
--- Comment #12 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:0258b73680e21fd96290af961c80966ac6b3cc68 commit r14-2886-g0258b73680e21fd96290af961c80966ac6b3cc68 Author: Andrew Pinski <apin...@marvell.com> Date: Sat Jul 29 16:59:10 2023 -0700 MATCH: PR 106164 : Optimize `(X CMP1 Y) AND/IOR (X CMP2 Y)` I noticed that there are patterns that optimize `(X CMP1 CST1) AND/IOR (X CMP2 CST2)` and we can easily extend them to support the `(X CMP1 Y) AND/IOR (X CMP2 Y)` by saying they compare equal. This allows for this kind of optimization for integral and pointer types (which have the same semantics). OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR tree-optimization/106164 * match.pd: Extend the `(X CMP1 CST1) AND/IOR (X CMP2 CST2)` patterns to support `(X CMP1 Y) AND/IOR (X CMP2 Y)`. gcc/testsuite/ChangeLog: PR tree-optimization/106164 * gcc.dg/tree-ssa/cmpbit-1.c: New test.