https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Bug ID: 96681 Summary: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables 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, int y) { return (x < 0) ^ (y < 0); } This can be optimized to `return (x ^ y) < 0;`. LLVM does this transformation, but GCC does not. This transformation can also be done with `return (x > -1) ^ (y > -1);`. There is also a similar transformation with `return (x > -1) ^ (y < 0);`, which can be optimized to `return ~(x ^ y) < 0;`.