Consider the following six functions.
https://godbolt.org/z/cTsd43jhh
bool test1(bool a, bool b)
{
return (a | b) ? (a ^ b) : (a & b);
}
bool test2(bool a, bool b)
{
return (a | b) ? (a & b) : (a ^ b);
}
bool test3(bool a, bool b)
{
return (a & b) ? (a | b) : (a ^ b);
}
bool test4(bool a, bool b)
{
return (a & b) ? (a ^ b) : (a | b);
}
bool test5(bool a, bool b)
{
return (a ^ b) ? (a | b) : (a & b);
}
bool test6(bool a, bool b)
{
return (a ^ b) ? (a & b) : (a | b);
}
Clang13 can simplify four of these, test1, test2, test3 and test4, while Clang trunk cannot. Neither Clang13 nor Clang trunk can simplify test5 and test6.