Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. This

takes care of all permutations of this pattern.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60290 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2008-11-30 13:08:13 +00:00
parent 7c7048ecc6
commit 7f0ef6b325
3 changed files with 55 additions and 10 deletions

View File

@@ -3993,6 +3993,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
std::swap(Op0, Op1);
}
}
if (Op1->hasOneUse() &&
match(Op1, m_Xor(m_Value(A), m_Value(B)))) {
if (B == Op0) { // B&(A^B) -> B&(B^A)
@@ -4005,6 +4006,24 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
return BinaryOperator::CreateAnd(A, NotB);
}
}
// (A&((~A)|B)) -> A&B
if (match(Op0, m_Or(m_Not(m_Value(A)), m_Value(B)))) {
if (A == Op1)
return BinaryOperator::CreateAnd(A, B);
}
if (match(Op0, m_Or(m_Value(A), m_Not(m_Value(B))))) {
if (B == Op1)
return BinaryOperator::CreateAnd(A, B);
}
if (match(Op1, m_Or(m_Not(m_Value(A)), m_Value(B)))) {
if (A == Op0)
return BinaryOperator::CreateAnd(A, B);
}
if (match(Op1, m_Or(m_Value(A), m_Not(m_Value(B))))) {
if (B == Op0)
return BinaryOperator::CreateAnd(A, B);
}
}
if (ICmpInst *RHS = dyn_cast<ICmpInst>(Op1)) {