Use simplifySelectWithICmpEq to handle the implied equalities from the icmp-or,
then both of ICMP_NE and ICMP_EQ will be addressed
(X | Y) == 0 ? X : 0 --> 0 (commuted 2 ways) (X | Y) != 0 ? 0 : X --> 0 (commuted 2 ways) --> will transform to above in instcombine
Not quite the code structure I had in mind. Rather than handling or in simplifySelectWithICmpEq, I'd expect something like this in here:
if (match(CmpLHS, m_Or(m_Value(X), m_Value(Y))) && match(CmpRHS, m_Zero())) { // X | Y == 0 implies X == 0 and Y == 0. if (Value *V = simplifySelectWithICmpEq(X, CmpRHS, TrueVal, FalseVal, Q, MaxRecurse)) return V; if (Value *V = simplifySelectWithICmpEq(Y, CmpRHS, TrueVal, FalseVal, Q, MaxRecurse)) return V; }That is, we handle the straightforward equality, and then we try to handle the implied equalities from the icmp or.