summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopInterchange.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopInterchange.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 5dc0de25971..2f50e2dd77f 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -812,7 +812,6 @@ bool LoopInterchangeLegality::currentLimitations() {
// A[j+1][i+2] = A[j][i]+k;
// }
// }
- bool FoundInduction = false;
Instruction *InnerIndexVarInc = nullptr;
if (InnerInductionVar->getIncomingBlock(0) == InnerLoopPreHeader)
InnerIndexVarInc =
@@ -828,17 +827,17 @@ bool LoopInterchangeLegality::currentLimitations() {
// we do not have any instruction between the induction variable and branch
// instruction.
- for (auto I = InnerLoopLatch->rbegin(), E = InnerLoopLatch->rend();
- I != E && !FoundInduction; ++I) {
- if (isa<BranchInst>(*I) || isa<CmpInst>(*I) || isa<TruncInst>(*I))
+ bool FoundInduction = false;
+ for (const Instruction &I : reverse(*InnerLoopLatch)) {
+ if (isa<BranchInst>(I) || isa<CmpInst>(I) || isa<TruncInst>(I))
continue;
- const Instruction &Ins = *I;
// We found an instruction. If this is not induction variable then it is not
// safe to split this loop latch.
- if (!Ins.isIdenticalTo(InnerIndexVarInc))
+ if (!I.isIdenticalTo(InnerIndexVarInc))
return true;
- else
- FoundInduction = true;
+
+ FoundInduction = true;
+ break;
}
// The loop latch ended and we didn't find the induction variable return as
// current limitation.
OpenPOWER on IntegriCloud