On 4/15/25 12:24 AM, Eikansh Gupta wrote:
The patterns can be simplified as shown below: (a != b) & ((a|b) != 0) -> (a != b) (a != b) | ((a|b) != 0) -> ((a|b) != 0) The similar simplification can be there for (a == b). This patch adds simplification for above patterns. The forwprop pass was modifying the patterns to some other form and they were not getting simplified. The patch also adds simplification for those patterns. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR 117760 gcc/ChangeLog: * match.pd ((a != b) and/or ((a | b) != 0)): New pattern. ((a == b) and/or (a | b) == 0): New pattern. ((a == b) & (a | b) == 0): New pattern. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr117760-1.c: New test. * gcc.dg/tree-ssa/pr117760-2.c: New test. * gcc.dg/tree-ssa/pr117760.c: New test.
Deferring to gcc-16 stage1. jeff