https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91882
Bug ID: 91882 Summary: boolean XOR tautology missed optimisation Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: SztfG at yandex dot ru Target Milestone: --- This functions is always return true regardless of the value of the arguments: bool bool_xor_test(bool a, bool b) { return (a != b) == ((a || b) && !(a && b)); } bool bool_xor_test2(bool a, bool b) { return (a ^ b) == ((a || b) && !(a && b)); } but compiler does not simplify to "return true;". Expression ((a || b) && !(a && b)) poorly optimized BUT! In this case: bool xor_test_unsigned_int(unsigned int a, unsigned int b) { return (a ^ b) == ((a | b) & ~(a & b)); } It actually simlified to "return true;" : movl $1, %eax ret