From ce13549761b6a22263e051dda09ef5122435008b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 20 Oct 2020 15:45:54 +0100 Subject: [PATCH] [InstCombine] foldOrOfICmps - use m_Specific instead of explicit comparisons. NFCI. --- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 2b8f5ff..9c9b3f4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2300,14 +2300,14 @@ Value *InstCombinerImpl::foldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, LHS->getType()->isIntOrIntVectorTy() && match(LHS1, m_APInt(LHSVal)) && match(RHS1, m_APInt(RHSVal)) && *LHSVal == *RHSVal && LHS->hasOneUse() && RHS->hasOneUse()) { - Value *LAddOpnd, *RAddOpnd; + Value *AddOpnd; const APInt *LAddVal, *RAddVal; - if (match(LHS0, m_Add(m_Value(LAddOpnd), m_APInt(LAddVal))) && - match(RHS0, m_Add(m_Value(RAddOpnd), m_APInt(RAddVal))) && + if (match(LHS0, m_Add(m_Value(AddOpnd), m_APInt(LAddVal))) && + match(RHS0, m_Add(m_Specific(AddOpnd), m_APInt(RAddVal))) && LAddVal->ugt(*LHSVal) && RAddVal->ugt(*LHSVal)) { APInt DiffC = *LAddVal ^ *RAddVal; - if (LAddOpnd == RAddOpnd && DiffC.isPowerOf2()) { + if (DiffC.isPowerOf2()) { const APInt *MaxAddC = nullptr; if (LAddVal->ult(*RAddVal)) MaxAddC = RAddVal; @@ -2326,7 +2326,7 @@ Value *InstCombinerImpl::foldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, if (LowRangeDiff.isPowerOf2() && LowRangeDiff == HighRangeDiff && RangeDiff.ugt(*LHSVal)) { Value *NewAnd = Builder.CreateAnd( - LAddOpnd, ConstantInt::get(LHS0->getType(), ~DiffC)); + AddOpnd, ConstantInt::get(LHS0->getType(), ~DiffC)); Value *NewAdd = Builder.CreateAdd( NewAnd, ConstantInt::get(LHS0->getType(), *MaxAddC)); return Builder.CreateICmp(LHS->getPredicate(), NewAdd, -- 2.7.4