diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Float2Int.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopDistribute.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 16 |
6 files changed, 28 insertions, 35 deletions
diff --git a/llvm/lib/Transforms/Scalar/Float2Int.cpp b/llvm/lib/Transforms/Scalar/Float2Int.cpp index bf37aa03eab..2ddc5436dbd 100644 --- a/llvm/lib/Transforms/Scalar/Float2Int.cpp +++ b/llvm/lib/Transforms/Scalar/Float2Int.cpp @@ -246,7 +246,7 @@ void Float2Int::walkBackwards(const SmallPtrSetImpl<Instruction*> &Roots) { // Walk forwards down the list of seen instructions, so we visit defs before // uses. void Float2Int::walkForwards() { - for (auto &It : make_range(SeenInsts.rbegin(), SeenInsts.rend())) { + for (auto &It : reverse(SeenInsts)) { if (It.second != unknownRange()) continue; @@ -511,7 +511,7 @@ Value *Float2Int::convert(Instruction *I, Type *ToTy) { // Perform dead code elimination on the instructions we just modified. void Float2Int::cleanup() { - for (auto &I : make_range(ConvertedInsts.rbegin(), ConvertedInsts.rend())) + for (auto &I : reverse(ConvertedInsts)) I.first->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp index a62a44be4cc..464db8e1811 100644 --- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp @@ -184,7 +184,7 @@ public: // Delete the instructions backwards, as it has a reduced likelihood of // having to update as many def-use and use-def chains. - for (auto *Inst : make_range(Unused.rbegin(), Unused.rend())) { + for (auto *Inst : reverse(Unused)) { if (!Inst->use_empty()) Inst->replaceAllUsesWith(UndefValue::get(Inst->getType())); Inst->eraseFromParent(); 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. diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 190fc5a2dc4..252ab928c1c 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2736,34 +2736,31 @@ void LSRInstance::CollectChains() { LatchPath.push_back(LoopHeader); // Walk the instruction stream from the loop header to the loop latch. - for (SmallVectorImpl<BasicBlock *>::reverse_iterator - BBIter = LatchPath.rbegin(), BBEnd = LatchPath.rend(); - BBIter != BBEnd; ++BBIter) { - for (BasicBlock::iterator I = (*BBIter)->begin(), E = (*BBIter)->end(); - I != E; ++I) { + for (BasicBlock *BB : reverse(LatchPath)) { + for (Instruction &I : *BB) { // Skip instructions that weren't seen by IVUsers analysis. - if (isa<PHINode>(I) || !IU.isIVUserOrOperand(&*I)) + if (isa<PHINode>(I) || !IU.isIVUserOrOperand(&I)) continue; // Ignore users that are part of a SCEV expression. This way we only // consider leaf IV Users. This effectively rediscovers a portion of // IVUsers analysis but in program order this time. - if (SE.isSCEVable(I->getType()) && !isa<SCEVUnknown>(SE.getSCEV(&*I))) + if (SE.isSCEVable(I.getType()) && !isa<SCEVUnknown>(SE.getSCEV(&I))) continue; // Remove this instruction from any NearUsers set it may be in. for (unsigned ChainIdx = 0, NChains = IVChainVec.size(); ChainIdx < NChains; ++ChainIdx) { - ChainUsersVec[ChainIdx].NearUsers.erase(&*I); + ChainUsersVec[ChainIdx].NearUsers.erase(&I); } // Search for operands that can be chained. SmallPtrSet<Instruction*, 4> UniqueOperands; - User::op_iterator IVOpEnd = I->op_end(); - User::op_iterator IVOpIter = findIVOperand(I->op_begin(), IVOpEnd, L, SE); + User::op_iterator IVOpEnd = I.op_end(); + User::op_iterator IVOpIter = findIVOperand(I.op_begin(), IVOpEnd, L, SE); while (IVOpIter != IVOpEnd) { Instruction *IVOpInst = cast<Instruction>(*IVOpIter); if (UniqueOperands.insert(IVOpInst).second) - ChainInstruction(&*I, IVOpInst, ChainUsersVec); + ChainInstruction(&I, IVOpInst, ChainUsersVec); IVOpIter = findIVOperand(std::next(IVOpIter), IVOpEnd, L, SE); } } // Continue walking down the instructions. diff --git a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp index e4af9916880..eb67aea37fc 100644 --- a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -377,11 +377,8 @@ StoreInst *MergedLoadStoreMotion::canSinkFromBlock(BasicBlock *BB1, StoreInst *Store0) { DEBUG(dbgs() << "can Sink? : "; Store0->dump(); dbgs() << "\n"); BasicBlock *BB0 = Store0->getParent(); - for (BasicBlock::reverse_iterator RBI = BB1->rbegin(), RBE = BB1->rend(); - RBI != RBE; ++RBI) { - Instruction *Inst = &*RBI; - - auto *Store1 = dyn_cast<StoreInst>(Inst); + for (Instruction &Inst : reverse(*BB1)) { + auto *Store1 = dyn_cast<StoreInst>(&Inst); if (!Store1) continue; diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index 802b3e476aa..ff46d81cb4d 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -501,21 +501,21 @@ void StructurizeCFG::collectInfos() { // Reset the visited nodes Visited.clear(); - for (RNVector::reverse_iterator OI = Order.rbegin(), OE = Order.rend(); - OI != OE; ++OI) { + for (RegionNode *RN : reverse(Order)) { - DEBUG(dbgs() << "Visiting: " << - ((*OI)->isSubRegion() ? "SubRegion with entry: " : "") << - (*OI)->getEntry()->getName() << " Loop Depth: " << LI->getLoopDepth((*OI)->getEntry()) << "\n"); + DEBUG(dbgs() << "Visiting: " + << (RN->isSubRegion() ? "SubRegion with entry: " : "") + << RN->getEntry()->getName() << " Loop Depth: " + << LI->getLoopDepth(RN->getEntry()) << "\n"); // Analyze all the conditions leading to a node - gatherPredicates(*OI); + gatherPredicates(RN); // Remember that we've seen this node - Visited.insert((*OI)->getEntry()); + Visited.insert(RN->getEntry()); // Find the last back edges - analyzeLoops(*OI); + analyzeLoops(RN); } } |