[llvm] r327641 - [InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 15 09:17:40 PDT 2018
Author: lebedevri
Date: Thu Mar 15 09:17:40 2018
New Revision: 327641
URL: http://llvm.org/viewvc/llvm-project?rev=327641&view=rev
Log:
[InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls
Preparation for D44425.
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=327641&r1=327640&r2=327641&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Mar 15 09:17:40 2018
@@ -2488,6 +2488,8 @@ static void setLimitsForBinOp(BinaryOper
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(C
// 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(C
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;
More information about the llvm-commits
mailing list