[llvm] 763b312 - [InstCombine] move comments closer to relevant code; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 13 06:16:44 PDT 2022
Author: Sanjay Patel
Date: 2022-08-13T09:16:33-04:00
New Revision: 763b31237f1fd4240f252837ceb861e6ff39ab9d
URL: https://github.com/llvm/llvm-project/commit/763b31237f1fd4240f252837ceb861e6ff39ab9d
DIFF: https://github.com/llvm/llvm-project/commit/763b31237f1fd4240f252837ceb861e6ff39ab9d.diff
LOG: [InstCombine] move comments closer to relevant code; NFC
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index d9e44b28d8690..843b4a4d81621 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2908,30 +2908,34 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
SwappedForXor = true;
}
- // A | ( A ^ B) -> A | B
- // A | (~A ^ B) -> A | ~B
- // (A & B) | (A ^ B)
- // ~A | (A ^ B) -> ~(A & B)
- // The swap above should always make Op0 the 'not' for the last case.
if (match(Op1, m_Xor(m_Value(A), m_Value(B)))) {
+ // A | (A ^ B) --> A | B
+ // B | (A ^ B) --> A | B
if (Op0 == A || Op0 == B)
return BinaryOperator::CreateOr(A, B);
+ // (A & B) | (A ^ B) --> A | B
+ // (B & A) | (A ^ B) --> A | B
if (match(Op0, m_And(m_Specific(A), m_Specific(B))) ||
match(Op0, m_And(m_Specific(B), m_Specific(A))))
return BinaryOperator::CreateOr(A, B);
+ // ~A | (A ^ B) --> ~(A & B)
+ // ~B | (A ^ B) --> ~(A & B)
+ // The swap above should always make Op0 the 'not'.
if ((Op0->hasOneUse() || Op1->hasOneUse()) &&
(match(Op0, m_Not(m_Specific(A))) || match(Op0, m_Not(m_Specific(B)))))
return BinaryOperator::CreateNot(Builder.CreateAnd(A, B));
+ // A | (~A ^ B) --> ~B | A
+ // B | (A ^ ~B) --> ~A | B
if (Op1->hasOneUse() && match(A, m_Not(m_Specific(Op0)))) {
- Value *Not = Builder.CreateNot(B, B->getName() + ".not");
- return BinaryOperator::CreateOr(Not, Op0);
+ Value *NotB = Builder.CreateNot(B, B->getName() + ".not");
+ return BinaryOperator::CreateOr(NotB, Op0);
}
if (Op1->hasOneUse() && match(B, m_Not(m_Specific(Op0)))) {
- Value *Not = Builder.CreateNot(A, A->getName() + ".not");
- return BinaryOperator::CreateOr(Not, Op0);
+ Value *NotA = Builder.CreateNot(A, A->getName() + ".not");
+ return BinaryOperator::CreateOr(NotA, Op0);
}
}
More information about the llvm-commits
mailing list