diff options
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index b33e414bf0..27f175058f 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -536,7 +536,7 @@ Instruction *Loop::getCanonicalInductionVariableIncrement() const { /// returns null. /// Value *Loop::getTripCount() const { - // Canonical loops will end with a 'setne I, V', where I is the incremented + // Canonical loops will end with a 'cmp ne I, V', where I is the incremented // canonical induction variable and V is the trip count of the loop. Instruction *Inc = getCanonicalInductionVariableIncrement(); if (Inc == 0) return 0; @@ -546,15 +546,17 @@ Value *Loop::getTripCount() const { IV->getIncomingBlock(contains(IV->getIncomingBlock(1))); if (BranchInst *BI = dyn_cast<BranchInst>(BackedgeBlock->getTerminator())) - if (BI->isConditional()) - if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition())) - if (SCI->getOperand(0) == Inc) + if (BI->isConditional()) { + if (ICmpInst *ICI = dyn_cast<ICmpInst>(BI->getCondition())) { + if (ICI->getOperand(0) == Inc) if (BI->getSuccessor(0) == getHeader()) { - if (SCI->getOpcode() == Instruction::SetNE) - return SCI->getOperand(1); - } else if (SCI->getOpcode() == Instruction::SetEQ) { - return SCI->getOperand(1); + if (ICI->getPredicate() == ICmpInst::ICMP_NE) + return ICI->getOperand(1); + } else if (ICI->getPredicate() == ICmpInst::ICMP_EQ) { + return ICI->getOperand(1); } + } + } return 0; } |