From: Roman Lebedev Date: Thu, 15 Mar 2018 16:17:40 +0000 (+0000) Subject: [InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls X-Git-Tag: llvmorg-7.0.0-rc1~10491 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c43d72e90e2346954190e1532976afd7a446a43;p=platform%2Fupstream%2Fllvm.git [InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls Preparation for D44425. llvm-svn: 327641 --- diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 67669c2..c382553 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2488,6 +2488,8 @@ static void setLimitsForBinOp(BinaryOperator &BO, APInt &Lower, APInt &Upper) { static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS, Value *RHS) { + Type *ITy = GetCompareTy(RHS); // The return type. + const APInt *C; if (!match(RHS, m_APInt(C))) return nullptr; @@ -2495,9 +2497,9 @@ static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS, // Rule out tautological comparisons (eg., ult 0 or uge 0). ConstantRange RHS_CR = ConstantRange::makeExactICmpRegion(Pred, *C); if (RHS_CR.isEmptySet()) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(ITy); if (RHS_CR.isFullSet()) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(ITy); // Find the range of possible values for binary operators. unsigned Width = C->getBitWidth(); @@ -2515,9 +2517,9 @@ static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS, if (!LHS_CR.isFullSet()) { if (RHS_CR.contains(LHS_CR)) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(ITy); if (RHS_CR.inverse().contains(LHS_CR)) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(ITy); } return nullptr;