mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 06:25:18 +00:00
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:
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user