aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 8716e9a..ace3ff8 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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)) {