summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-11-30 13:08:13 +0000
committerBill Wendling <isanbard@gmail.com>2008-11-30 13:08:13 +0000
commit9eef421e12c83a1783ff525ccb80d6799f2a495c (patch)
tree4f013a04f3c1c1cb5b4eb2437030bad1df19aad6 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent2fe322982475f900cc369ef245bb9de656cce286 (diff)
downloadbcm5719-llvm-9eef421e12c83a1783ff525ccb80d6799f2a495c.tar.gz
bcm5719-llvm-9eef421e12c83a1783ff525ccb80d6799f2a495c.zip
Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. This
takes care of all permutations of this pattern. llvm-svn: 60290
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 8716e9a8a6c..ace3ff80d4f 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -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)) {
OpenPOWER on IntegriCloud