diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp b/contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp index 66aab4c195c8..b35fb2a190f6 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/LoopInfo.cpp @@ -301,15 +301,16 @@ PHINode *Loop::getInductionVariable(ScalarEvolution &SE) const { if (!CmpInst) return nullptr; - Instruction *LatchCmpOp0 = dyn_cast<Instruction>(CmpInst->getOperand(0)); - Instruction *LatchCmpOp1 = dyn_cast<Instruction>(CmpInst->getOperand(1)); + Value *LatchCmpOp0 = CmpInst->getOperand(0); + Value *LatchCmpOp1 = CmpInst->getOperand(1); for (PHINode &IndVar : Header->phis()) { InductionDescriptor IndDesc; if (!InductionDescriptor::isInductionPHI(&IndVar, this, &SE, IndDesc)) continue; - Instruction *StepInst = IndDesc.getInductionBinOp(); + BasicBlock *Latch = getLoopLatch(); + Value *StepInst = IndVar.getIncomingValueForBlock(Latch); // case 1: // IndVar = phi[{InitialValue, preheader}, {StepInst, latch}] @@ -1102,6 +1103,11 @@ llvm::Optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop, return IntMD->getSExtValue(); } +int llvm::getIntLoopAttribute(const Loop *TheLoop, StringRef Name, + int Default) { + return getOptionalIntLoopAttribute(TheLoop, Name).getValueOr(Default); +} + static const char *LLVMLoopMustProgress = "llvm.loop.mustprogress"; bool llvm::hasMustProgress(const Loop *L) { |