From d7708773288c4f33bf98c724f7a486b5973b8cc6 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 24 Jun 2016 04:05:21 +0000 Subject: Switch more loops to be range-based This makes the code a little more concise, no functional change is intended. llvm-svn: 273644 --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/LoopInterchange.cpp') diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index 5dc0de2..2f50e2d 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(*I) || isa(*I) || isa(*I)) + bool FoundInduction = false; + for (const Instruction &I : reverse(*InnerLoopLatch)) { + if (isa(I) || isa(I) || isa(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. -- cgit v1.1