From ee8bc9ac4f4aa7f515b949aa3bea0445cadd23e4 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 10 Nov 2015 23:56:15 +0000 Subject: [PATCH] [ValueTracking] Use m_APInt instead of m_ConstantInt, NFC This change would add functionality if isImpliedCondition worked on vector types; but since it bail out on vector predicates this change is an NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252672 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 8d39e4e542d..e4cbdb9249f 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -4103,6 +4103,7 @@ static bool isTruePredicate(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const DataLayout &DL, unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) { + assert(!LHS->getType()->isVectorTy() && "TODO: extend to handle vectors!"); if (ICmpInst::isTrueWhenEqual(Pred) && LHS == RHS) return true; @@ -4112,27 +4113,27 @@ static bool isTruePredicate(CmpInst::Predicate Pred, Value *LHS, Value *RHS, case CmpInst::ICMP_SLT: case CmpInst::ICMP_SLE: { - ConstantInt *CI; + const APInt *C; // LHS s< LHS +_{nsw} C if C > 0 // LHS s<= LHS +_{nsw} C if C >= 0 - if (match(RHS, m_NSWAdd(m_Specific(LHS), m_ConstantInt(CI)))) { + if (match(RHS, m_NSWAdd(m_Specific(LHS), m_APInt(C)))) { if (Pred == CmpInst::ICMP_SLT) - return CI->getValue().isStrictlyPositive(); - return !CI->isNegative(); + return C->isStrictlyPositive(); + return !C->isNegative(); } return false; } case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE: { - ConstantInt *CI; + const APInt *C; // LHS u< LHS +_{nuw} C if C != 0 // LHS u<= LHS +_{nuw} C - if (match(RHS, m_NUWAdd(m_Specific(LHS), m_ConstantInt(CI)))) { + if (match(RHS, m_NUWAdd(m_Specific(LHS), m_APInt(C)))) { if (Pred == CmpInst::ICMP_ULT) - return !CI->isZero(); + return C->isMinValue(); return true; } return false; -- 2.34.1