[llvm] 7b4a828 - [InstCombine] foldOrOfICmps - use m_Specific instead of explicit comparisons. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 21 04:10:20 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-21T11:53:45+01:00
New Revision: 7b4a828452f4f59adf1561697b853e78efd006a9
URL: https://github.com/llvm/llvm-project/commit/7b4a828452f4f59adf1561697b853e78efd006a9
DIFF: https://github.com/llvm/llvm-project/commit/7b4a828452f4f59adf1561697b853e78efd006a9.diff
LOG: [InstCombine] foldOrOfICmps - use m_Specific instead of explicit comparisons. NFCI.
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 b34ba4e7908f..21a092449734 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2301,15 +2301,15 @@ Value *InstCombinerImpl::foldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
LHSC->getType() == RHSC->getType() &&
LHSC->getValue() == (RHSC->getValue())) {
- Value *LAddOpnd, *RAddOpnd;
+ Value *AddOpnd;
ConstantInt *LAddC, *RAddC;
- if (match(LHS0, m_Add(m_Value(LAddOpnd), m_ConstantInt(LAddC))) &&
- match(RHS0, m_Add(m_Value(RAddOpnd), m_ConstantInt(RAddC))) &&
+ if (match(LHS0, m_Add(m_Value(AddOpnd), m_ConstantInt(LAddC))) &&
+ match(RHS0, m_Add(m_Specific(AddOpnd), m_ConstantInt(RAddC))) &&
LAddC->getValue().ugt(LHSC->getValue()) &&
RAddC->getValue().ugt(LHSC->getValue())) {
APInt DiffC = LAddC->getValue() ^ RAddC->getValue();
- if (LAddOpnd == RAddOpnd && DiffC.isPowerOf2()) {
+ if (DiffC.isPowerOf2()) {
ConstantInt *MaxAddC = nullptr;
if (LAddC->getValue().ult(RAddC->getValue()))
MaxAddC = RAddC;
@@ -2329,7 +2329,7 @@ Value *InstCombinerImpl::foldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
RangeDiff.ugt(LHSC->getValue())) {
Value *MaskC = ConstantInt::get(LAddC->getType(), ~DiffC);
- Value *NewAnd = Builder.CreateAnd(LAddOpnd, MaskC);
+ Value *NewAnd = Builder.CreateAnd(AddOpnd, MaskC);
Value *NewAdd = Builder.CreateAdd(NewAnd, MaxAddC);
return Builder.CreateICmp(LHS->getPredicate(), NewAdd, LHSC);
}
More information about the llvm-commits
mailing list