https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96691
Bug ID: 96691 Summary: Failure to optimize not+or+xor with constants to and+xor with bitwise not-ed constants Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- int f(int x) { return (~x | 123) ^ 321; } This can be optimized to `return (x & ~123) ^ ~321;` (and the same transformation can be applied with any constants replacing 123 and 321). This transformation is done by LLVM, but not by GCC.