From: Artur Pilipenko Date: Mon, 8 Aug 2016 14:08:37 +0000 (+0000) Subject: [LVI] NFC. Extract LHS, RHS, Predicate locals in getValueFromCondition X-Git-Tag: llvmorg-4.0.0-rc1~13062 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21472910c101f169d4cd364e474120049dbd801b;p=platform%2Fupstream%2Fllvm.git [LVI] NFC. Extract LHS, RHS, Predicate locals in getValueFromCondition llvm-svn: 278007 --- diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 2f5fbec..306a1cf 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1183,30 +1183,33 @@ bool getValueFromCondition(Value *Val, Value *Cond, LVILatticeVal &Result, if (!ICI) return false; - if (isa(ICI->getOperand(1))) { - if (ICI->isEquality() && ICI->getOperand(0) == Val) { + Value *LHS = ICI->getOperand(0); + Value *RHS = ICI->getOperand(1); + CmpInst::Predicate Predicate = ICI->getPredicate(); + + if (isa(RHS)) { + if (ICI->isEquality() && LHS == Val) { // We know that V has the RHS constant if this is a true SETEQ or // false SETNE. - if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) - Result = LVILatticeVal::get(cast(ICI->getOperand(1))); + if (isTrueDest == (Predicate == ICmpInst::ICMP_EQ)) + Result = LVILatticeVal::get(cast(RHS)); else - Result = LVILatticeVal::getNot(cast(ICI->getOperand(1))); + Result = LVILatticeVal::getNot(cast(RHS)); return true; } // Recognize the range checking idiom that InstCombine produces. // (X-C1) u< C2 --> [C1, C1+C2) ConstantInt *NegOffset = nullptr; - if (ICI->getPredicate() == ICmpInst::ICMP_ULT) - match(ICI->getOperand(0), m_Add(m_Specific(Val), - m_ConstantInt(NegOffset))); + if (Predicate == ICmpInst::ICMP_ULT) + match(LHS, m_Add(m_Specific(Val), m_ConstantInt(NegOffset))); - ConstantInt *CI = dyn_cast(ICI->getOperand(1)); - if (CI && (ICI->getOperand(0) == Val || NegOffset)) { + ConstantInt *CI = dyn_cast(RHS); + if (CI && (LHS == Val || NegOffset)) { // Calculate the range of values that are allowed by the comparison ConstantRange CmpRange(CI->getValue()); ConstantRange TrueValues = - ConstantRange::makeAllowedICmpRegion(ICI->getPredicate(), CmpRange); + ConstantRange::makeAllowedICmpRegion(Predicate, CmpRange); if (NegOffset) // Apply the offset from above. TrueValues = TrueValues.subtract(NegOffset->getValue());