https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
Bug ID: 101650 Summary: (len | N) == len is transformed to len & N != 0 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- While looking at PR 101590, I noticed this one. #include <stddef.h> const size_t N = 4; bool foo(size_t len) { size_t newlen = len | N; return newlen == len; } (for cmp (NE EQ) icmp (EQ NE) (simplify (cmp (bit_ior @0 INTEGER_CST@1) @0) (icmp (bit_and @0 @1) ({ build_zero_cst (TREE_TYPE (@0)); }) ) ) This is already done for bit_and.