[polly] r210170 - Use range-based for loops
Tobias Grosser
tobias at grosser.es
Wed Jun 4 01:06:41 PDT 2014
Author: grosser
Date: Wed Jun 4 03:06:40 2014
New Revision: 210170
URL: http://llvm.org/viewvc/llvm-project?rev=210170&view=rev
Log:
Use range-based for loops
Modified:
polly/trunk/lib/Analysis/Dependences.cpp
polly/trunk/lib/CodeGen/BlockGenerators.cpp
polly/trunk/lib/CodeGen/IslAst.cpp
polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
polly/trunk/lib/CodeGen/LoopGenerators.cpp
Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Wed Jun 4 03:06:40 2014
@@ -76,9 +76,7 @@ void Dependences::collectInfo(Scop &S, i
*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(Stat
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 *getCombinedScheduleForSpa
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);
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Wed Jun 4 03:06:40 2014
@@ -229,10 +229,7 @@ void BlockGenerator::copyInstScalar(cons
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 &G
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(con
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::extractScalar
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::extractScalar
// 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);
}
Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Wed Jun 4 03:06:40 2014
@@ -395,8 +395,7 @@ IslAst::IslAst(Scop *Scop, Dependences &
__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());
Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Wed Jun 4 03:06:40 2014
@@ -1014,9 +1014,8 @@ void IslNodeBuilder::createSubstitutions
int i = 0;
Value *OldValue = IDToValue[IteratorID];
- for (std::vector<Value *>::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++;
Modified: polly/trunk/lib/CodeGen/LoopGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/LoopGenerators.cpp?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/LoopGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/LoopGenerators.cpp Wed Jun 4 03:06:40 2014
@@ -240,8 +240,8 @@ Function *OMPGenerator::createSubfunctio
Value *OMPGenerator::loadValuesIntoStruct(SetVector<Value *> &Values) {
std::vector<Type *> 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");
More information about the llvm-commits
mailing list