https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101591
Bug ID: 101591 Summary: (a|b) ==/!= a -> (b & ~a) ==/!= 0 on gimple 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: --- Take: bool f(unsigned a, unsigned b) { return (a|b) == a; } This should be optimized to: bool f(unsigned a, unsigned b) { return (b & ~a) ==/!= 0; } It might be only best if you we do for constant b's though.