From 91f5b262684dbe2dd0dbf7c6d10840a8cbcc1880 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Wed, 4 Jun 2014 08:06:40 +0000 Subject: [PATCH] Use range-based for loops llvm-svn: 210170 --- polly/lib/Analysis/Dependences.cpp | 13 ++++--------- polly/lib/CodeGen/BlockGenerators.cpp | 32 ++++++++++++-------------------- polly/lib/CodeGen/IslAst.cpp | 3 +-- polly/lib/CodeGen/IslCodeGeneration.cpp | 5 ++--- polly/lib/CodeGen/LoopGenerators.cpp | 4 ++-- 5 files changed, 21 insertions(+), 36 deletions(-) diff --git a/polly/lib/Analysis/Dependences.cpp b/polly/lib/Analysis/Dependences.cpp index c24120c..c6d258a 100644 --- a/polly/lib/Analysis/Dependences.cpp +++ b/polly/lib/Analysis/Dependences.cpp @@ -76,9 +76,7 @@ void Dependences::collectInfo(Scop &S, isl_union_map **Read, *MayWrite = isl_union_map_empty(isl_space_copy(Space)); *Schedule = isl_union_map_empty(Space); - for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; - + for (ScopStmt *Stmt : S) { for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(), ME = Stmt->memacc_end(); MI != ME; ++MI) { @@ -195,12 +193,10 @@ bool Dependences::isValidScattering(StatementToIslMapTy *NewScattering) { isl_space *ScatteringSpace = 0; - for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; - + for (ScopStmt *Stmt : S) { isl_map *StmtScat; - if (NewScattering->find(*SI) == NewScattering->end()) + if (NewScattering->find(Stmt) == NewScattering->end()) StmtScat = Stmt->getScattering(); else StmtScat = isl_map_copy((*NewScattering)[Stmt]); @@ -234,8 +230,7 @@ isl_union_map *getCombinedScheduleForSpace(Scop *scop, unsigned dimLevel) { isl_space *Space = scop->getParamSpace(); isl_union_map *schedule = isl_union_map_empty(Space); - for (Scop::iterator SI = scop->begin(), SE = scop->end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; + for (ScopStmt *Stmt : *scop) { unsigned remainingDimensions = Stmt->getNumScattering() - dimLevel; isl_map *Scattering = isl_map_project_out( Stmt->getScattering(), isl_dim_out, dimLevel, remainingDimensions); diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 7d36e83..0643fbe 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -229,10 +229,7 @@ void BlockGenerator::copyInstScalar(const Instruction *Inst, ValueMapT &BBMap, Instruction *NewInst = Inst->clone(); // Replace old operands with the new ones. - for (Instruction::const_op_iterator OI = Inst->op_begin(), - OE = Inst->op_end(); - OI != OE; ++OI) { - Value *OldOperand = *OI; + for (Value *OldOperand : Inst->operands()) { Value *NewOperand = getNewValue(OldOperand, BBMap, GlobalMap, LTS, getLoopForInst(Inst)); @@ -388,9 +385,8 @@ void BlockGenerator::copyBB(ValueMapT &GlobalMap, LoopToScevMapT <S) { ValueMapT BBMap; - for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end(); II != IE; - ++II) - copyInstruction(II, BBMap, GlobalMap, LTS); + for (Instruction &Inst : *BB) + copyInstruction(&Inst, BBMap, GlobalMap, LTS); } VectorBlockGenerator::VectorBlockGenerator(PollyIRBuilder &B, @@ -611,10 +607,8 @@ void VectorBlockGenerator::copyStore(const StoreInst *Store, bool VectorBlockGenerator::hasVectorOperands(const Instruction *Inst, ValueMapT &VectorMap) { - for (Instruction::const_op_iterator OI = Inst->op_begin(), - OE = Inst->op_end(); - OI != OE; ++OI) - if (VectorMap.count(*OI)) + for (Value *Operand : Inst->operands()) + if (VectorMap.count(Operand)) return true; return false; } @@ -625,10 +619,8 @@ bool VectorBlockGenerator::extractScalarValues(const Instruction *Inst, bool HasVectorOperand = false; int VectorWidth = getVectorWidth(); - for (Instruction::const_op_iterator OI = Inst->op_begin(), - OE = Inst->op_end(); - OI != OE; ++OI) { - ValueMapT::iterator VecOp = VectorMap.find(*OI); + for (Value *Operand : Inst->operands()) { + ValueMapT::iterator VecOp = VectorMap.find(Operand); if (VecOp == VectorMap.end()) continue; @@ -642,10 +634,11 @@ bool VectorBlockGenerator::extractScalarValues(const Instruction *Inst, // If there is one scalar extracted, all scalar elements should have // already been extracted by the code here. So no need to check for the // existance of all of them. - if (SM.count(*OI)) + if (SM.count(Operand)) break; - SM[*OI] = Builder.CreateExtractElement(NewVector, Builder.getInt32(i)); + SM[Operand] = + Builder.CreateExtractElement(NewVector, Builder.getInt32(i)); } } @@ -744,7 +737,6 @@ void VectorBlockGenerator::copyBB() { VectorValueMapT ScalarBlockMap(getVectorWidth()); ValueMapT VectorBlockMap; - for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end(); II != IE; - ++II) - copyInstruction(II, VectorBlockMap, ScalarBlockMap); + for (Instruction &Inst : *BB) + copyInstruction(&Inst, VectorBlockMap, ScalarBlockMap); } diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp index e2fe4ad..0e2ddcc 100644 --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -395,8 +395,7 @@ IslAst::IslAst(Scop *Scop, Dependences &D) : S(Scop) { __isl_give isl_union_map *IslAst::getSchedule() { isl_union_map *Schedule = isl_union_map_empty(S->getParamSpace()); - for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; + for (ScopStmt *Stmt : *S) { isl_map *StmtSchedule = Stmt->getScattering(); StmtSchedule = isl_map_intersect_domain(StmtSchedule, Stmt->getDomain()); diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index f872a98..ab8fb8b 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -1014,9 +1014,8 @@ void IslNodeBuilder::createSubstitutionsVector( int i = 0; Value *OldValue = IDToValue[IteratorID]; - for (std::vector::iterator II = IVS.begin(), IE = IVS.end(); - II != IE; ++II) { - IDToValue[IteratorID] = *II; + for (Value *IV : IVS) { + IDToValue[IteratorID] = IV; createSubstitutions(isl_pw_multi_aff_copy(PMA), isl_ast_build_copy(Context), Stmt, VMap[i], VLTS[i]); i++; diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp index df2f9cc..52a47ef 100644 --- a/polly/lib/CodeGen/LoopGenerators.cpp +++ b/polly/lib/CodeGen/LoopGenerators.cpp @@ -240,8 +240,8 @@ Function *OMPGenerator::createSubfunctionDefinition() { Value *OMPGenerator::loadValuesIntoStruct(SetVector &Values) { std::vector Members; - for (unsigned i = 0; i < Values.size(); i++) - Members.push_back(Values[i]->getType()); + for (Value *V : Values) + Members.push_back(V->getType()); StructType *Ty = StructType::get(Builder.getContext(), Members); Value *Struct = Builder.CreateAlloca(Ty, 0, "omp.userContext"); -- 2.7.4