@@ -6065,13 +6065,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
60656065 LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n");
60666066
60676067 TE->setOperandsInOrder();
6068- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6068+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
60696069 ValueList Operands;
60706070 // Prepare the operand vector.
60716071 for (Value *V : VL)
6072- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6072+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
60736073
6074- buildTree_rec(Operands, Depth + 1, {TE, i });
6074+ buildTree_rec(Operands, Depth + 1, {TE, I });
60756075 }
60766076 return;
60776077 }
@@ -6145,13 +6145,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
61456145 }
61466146
61476147 TE->setOperandsInOrder();
6148- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6148+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
61496149 ValueList Operands;
61506150 // Prepare the operand vector.
61516151 for (Value *V : VL)
6152- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6152+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
61536153
6154- buildTree_rec(Operands, Depth + 1, {TE, i });
6154+ buildTree_rec(Operands, Depth + 1, {TE, I });
61556155 }
61566156 return;
61576157 }
@@ -6246,18 +6246,18 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
62466246 TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
62476247 ReuseShuffleIndicies);
62486248 TE->setOperandsInOrder();
6249- for (unsigned i = 0, e = CI->arg_size(); i != e; ++i ) {
6249+ for (unsigned I : seq<unsigned>( 0, CI->arg_size()) ) {
62506250 // For scalar operands no need to create an entry since no need to
62516251 // vectorize it.
6252- if (isVectorIntrinsicWithScalarOpAtArg(ID, i ))
6252+ if (isVectorIntrinsicWithScalarOpAtArg(ID, I ))
62536253 continue;
62546254 ValueList Operands;
62556255 // Prepare the operand vector.
62566256 for (Value *V : VL) {
62576257 auto *CI2 = cast<CallInst>(V);
6258- Operands.push_back(CI2->getArgOperand(i ));
6258+ Operands.push_back(CI2->getArgOperand(I ));
62596259 }
6260- buildTree_rec(Operands, Depth + 1, {TE, i });
6260+ buildTree_rec(Operands, Depth + 1, {TE, I });
62616261 }
62626262 return;
62636263 }
@@ -6308,13 +6308,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
63086308 }
63096309
63106310 TE->setOperandsInOrder();
6311- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6311+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
63126312 ValueList Operands;
63136313 // Prepare the operand vector.
63146314 for (Value *V : VL)
6315- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6315+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
63166316
6317- buildTree_rec(Operands, Depth + 1, {TE, i });
6317+ buildTree_rec(Operands, Depth + 1, {TE, I });
63186318 }
63196319 return;
63206320 }
@@ -11111,9 +11111,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1111111111 // visit every block once.
1111211112 SmallPtrSet<BasicBlock *, 4> VisitedBBs;
1111311113
11114- for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i ) {
11114+ for (unsigned I : seq<unsigned>( 0, PH->getNumIncomingValues()) ) {
1111511115 ValueList Operands;
11116- BasicBlock *IBB = PH->getIncomingBlock(i );
11116+ BasicBlock *IBB = PH->getIncomingBlock(I );
1111711117
1111811118 // Stop emission if all incoming values are generated.
1111911119 if (NewPhi->getNumIncomingValues() == PH->getNumIncomingValues()) {
@@ -11128,9 +11128,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1112811128
1112911129 Builder.SetInsertPoint(IBB->getTerminator());
1113011130 Builder.SetCurrentDebugLocation(PH->getDebugLoc());
11131- Value *Vec = vectorizeOperand(E, i , /*PostponedPHIs=*/true);
11131+ Value *Vec = vectorizeOperand(E, I , /*PostponedPHIs=*/true);
1113211132 if (VecTy != Vec->getType()) {
11133- assert(MinBWs.contains(PH->getIncomingValue(i )) &&
11133+ assert(MinBWs.contains(PH->getIncomingValue(I )) &&
1113411134 "Expected item in MinBWs.");
1113511135 Vec = Builder.CreateIntCast(Vec, VecTy, It->second.second);
1113611136 }
@@ -11640,27 +11640,27 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1164011640 if (isVectorIntrinsicWithOverloadTypeAtArg(IID, -1))
1164111641 TysForDecl.push_back(
1164211642 FixedVectorType::get(CI->getType(), E->Scalars.size()));
11643- for (int j = 0, e = CI->arg_size(); j < e; ++j ) {
11643+ for (unsigned I : seq<unsigned>( 0, CI->arg_size()) ) {
1164411644 ValueList OpVL;
1164511645 // Some intrinsics have scalar arguments. This argument should not be
1164611646 // vectorized.
11647- if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, j )) {
11647+ if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, I )) {
1164811648 CallInst *CEI = cast<CallInst>(VL0);
11649- ScalarArg = CEI->getArgOperand(j );
11650- OpVecs.push_back(CEI->getArgOperand(j ));
11651- if (isVectorIntrinsicWithOverloadTypeAtArg(IID, j ))
11649+ ScalarArg = CEI->getArgOperand(I );
11650+ OpVecs.push_back(CEI->getArgOperand(I ));
11651+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, I ))
1165211652 TysForDecl.push_back(ScalarArg->getType());
1165311653 continue;
1165411654 }
1165511655
11656- Value *OpVec = vectorizeOperand(E, j , PostponedPHIs);
11656+ Value *OpVec = vectorizeOperand(E, I , PostponedPHIs);
1165711657 if (E->VectorizedValue) {
1165811658 LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
1165911659 return E->VectorizedValue;
1166011660 }
11661- LLVM_DEBUG(dbgs() << "SLP: OpVec[" << j << "]: " << *OpVec << "\n");
11661+ LLVM_DEBUG(dbgs() << "SLP: OpVec[" << I << "]: " << *OpVec << "\n");
1166211662 OpVecs.push_back(OpVec);
11663- if (isVectorIntrinsicWithOverloadTypeAtArg(IID, j ))
11663+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, I ))
1166411664 TysForDecl.push_back(OpVec->getType());
1166511665 }
1166611666
@@ -12079,18 +12079,18 @@ Value *BoUpSLP::vectorizeTree(
1207912079 // Find the insertion point for the extractelement lane.
1208012080 if (auto *VecI = dyn_cast<Instruction>(Vec)) {
1208112081 if (PHINode *PH = dyn_cast<PHINode>(User)) {
12082- for (int i = 0, e = PH->getNumIncomingValues(); i != e; ++i ) {
12083- if (PH->getIncomingValue(i ) == Scalar) {
12082+ for (unsigned I : seq<unsigned>( 0, PH->getNumIncomingValues()) ) {
12083+ if (PH->getIncomingValue(I ) == Scalar) {
1208412084 Instruction *IncomingTerminator =
12085- PH->getIncomingBlock(i )->getTerminator();
12085+ PH->getIncomingBlock(I )->getTerminator();
1208612086 if (isa<CatchSwitchInst>(IncomingTerminator)) {
1208712087 Builder.SetInsertPoint(VecI->getParent(),
1208812088 std::next(VecI->getIterator()));
1208912089 } else {
12090- Builder.SetInsertPoint(PH->getIncomingBlock(i )->getTerminator());
12090+ Builder.SetInsertPoint(PH->getIncomingBlock(I )->getTerminator());
1209112091 }
1209212092 Value *NewInst = ExtractAndExtendIfNeeded(Vec);
12093- PH->setOperand(i , NewInst);
12093+ PH->setOperand(I , NewInst);
1209412094 }
1209512095 }
1209612096 } else {
@@ -16036,41 +16036,41 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1603616036 return I->use_empty() &&
1603716037 (I->getType()->isVoidTy() || isa<CallInst, InvokeInst>(I));
1603816038 };
16039- for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e ; ++it ) {
16039+ for (BasicBlock::iterator It = BB->begin(), E = BB->end(); It != E ; ++It ) {
1604016040 // Skip instructions with scalable type. The num of elements is unknown at
1604116041 // compile-time for scalable type.
16042- if (isa<ScalableVectorType>(it ->getType()))
16042+ if (isa<ScalableVectorType>(It ->getType()))
1604316043 continue;
1604416044
1604516045 // Skip instructions marked for the deletion.
16046- if (R.isDeleted(&*it ))
16046+ if (R.isDeleted(&*It ))
1604716047 continue;
1604816048 // We may go through BB multiple times so skip the one we have checked.
16049- if (!VisitedInstrs.insert(&*it ).second) {
16050- if (HasNoUsers(&*it ) &&
16051- VectorizeInsertsAndCmps(/*VectorizeCmps=*/it ->isTerminator())) {
16049+ if (!VisitedInstrs.insert(&*It ).second) {
16050+ if (HasNoUsers(&*It ) &&
16051+ VectorizeInsertsAndCmps(/*VectorizeCmps=*/It ->isTerminator())) {
1605216052 // We would like to start over since some instructions are deleted
1605316053 // and the iterator may become invalid value.
1605416054 Changed = true;
16055- it = BB->begin();
16056- e = BB->end();
16055+ It = BB->begin();
16056+ E = BB->end();
1605716057 }
1605816058 continue;
1605916059 }
1606016060
16061- if (isa<DbgInfoIntrinsic>(it ))
16061+ if (isa<DbgInfoIntrinsic>(It ))
1606216062 continue;
1606316063
1606416064 // Try to vectorize reductions that use PHINodes.
16065- if (PHINode *P = dyn_cast<PHINode>(it )) {
16065+ if (PHINode *P = dyn_cast<PHINode>(It )) {
1606616066 // Check that the PHI is a reduction PHI.
1606716067 if (P->getNumIncomingValues() == 2) {
1606816068 // Try to match and vectorize a horizontal reduction.
1606916069 Instruction *Root = getReductionInstr(DT, P, BB, LI);
1607016070 if (Root && vectorizeRootInstruction(P, Root, BB, R, TTI)) {
1607116071 Changed = true;
16072- it = BB->begin();
16073- e = BB->end();
16072+ It = BB->begin();
16073+ E = BB->end();
1607416074 continue;
1607516075 }
1607616076 }
@@ -16095,9 +16095,9 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1609516095 continue;
1609616096 }
1609716097
16098- if (HasNoUsers(&*it )) {
16098+ if (HasNoUsers(&*It )) {
1609916099 bool OpsChanged = false;
16100- auto *SI = dyn_cast<StoreInst>(it );
16100+ auto *SI = dyn_cast<StoreInst>(It );
1610116101 bool TryToVectorizeRoot = ShouldStartVectorizeHorAtStore || !SI;
1610216102 if (SI) {
1610316103 auto *I = Stores.find(getUnderlyingObject(SI->getPointerOperand()));
@@ -16111,7 +16111,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1611116111 SI->getValueOperand()->hasOneUse();
1611216112 }
1611316113 if (TryToVectorizeRoot) {
16114- for (auto *V : it ->operand_values()) {
16114+ for (auto *V : It ->operand_values()) {
1611516115 // Postponed instructions should not be vectorized here, delay their
1611616116 // vectorization.
1611716117 if (auto *VI = dyn_cast<Instruction>(V);
@@ -16124,21 +16124,21 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1612416124 // top-tree instructions to try to vectorize as many instructions as
1612516125 // possible.
1612616126 OpsChanged |=
16127- VectorizeInsertsAndCmps(/*VectorizeCmps=*/it ->isTerminator());
16127+ VectorizeInsertsAndCmps(/*VectorizeCmps=*/It ->isTerminator());
1612816128 if (OpsChanged) {
1612916129 // We would like to start over since some instructions are deleted
1613016130 // and the iterator may become invalid value.
1613116131 Changed = true;
16132- it = BB->begin();
16133- e = BB->end();
16132+ It = BB->begin();
16133+ E = BB->end();
1613416134 continue;
1613516135 }
1613616136 }
1613716137
16138- if (isa<InsertElementInst, InsertValueInst>(it ))
16139- PostProcessInserts.insert(&*it );
16140- else if (isa<CmpInst>(it ))
16141- PostProcessCmps.insert(cast<CmpInst>(&*it ));
16138+ if (isa<InsertElementInst, InsertValueInst>(It ))
16139+ PostProcessInserts.insert(&*It );
16140+ else if (isa<CmpInst>(It ))
16141+ PostProcessCmps.insert(cast<CmpInst>(&*It ));
1614216142 }
1614316143
1614416144 return Changed;
0 commit comments