@@ -6065,13 +6065,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6065
6065
LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n");
6066
6066
6067
6067
TE->setOperandsInOrder();
6068
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6068
+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
6069
6069
ValueList Operands;
6070
6070
// Prepare the operand vector.
6071
6071
for (Value *V : VL)
6072
- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6072
+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
6073
6073
6074
- buildTree_rec(Operands, Depth + 1, {TE, i });
6074
+ buildTree_rec(Operands, Depth + 1, {TE, I });
6075
6075
}
6076
6076
return;
6077
6077
}
@@ -6145,13 +6145,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6145
6145
}
6146
6146
6147
6147
TE->setOperandsInOrder();
6148
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6148
+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
6149
6149
ValueList Operands;
6150
6150
// Prepare the operand vector.
6151
6151
for (Value *V : VL)
6152
- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6152
+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
6153
6153
6154
- buildTree_rec(Operands, Depth + 1, {TE, i });
6154
+ buildTree_rec(Operands, Depth + 1, {TE, I });
6155
6155
}
6156
6156
return;
6157
6157
}
@@ -6246,18 +6246,18 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6246
6246
TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
6247
6247
ReuseShuffleIndicies);
6248
6248
TE->setOperandsInOrder();
6249
- for (unsigned i = 0, e = CI->arg_size(); i != e; ++i ) {
6249
+ for (unsigned I : seq<unsigned>( 0, CI->arg_size()) ) {
6250
6250
// For scalar operands no need to create an entry since no need to
6251
6251
// vectorize it.
6252
- if (isVectorIntrinsicWithScalarOpAtArg(ID, i ))
6252
+ if (isVectorIntrinsicWithScalarOpAtArg(ID, I ))
6253
6253
continue;
6254
6254
ValueList Operands;
6255
6255
// Prepare the operand vector.
6256
6256
for (Value *V : VL) {
6257
6257
auto *CI2 = cast<CallInst>(V);
6258
- Operands.push_back(CI2->getArgOperand(i ));
6258
+ Operands.push_back(CI2->getArgOperand(I ));
6259
6259
}
6260
- buildTree_rec(Operands, Depth + 1, {TE, i });
6260
+ buildTree_rec(Operands, Depth + 1, {TE, I });
6261
6261
}
6262
6262
return;
6263
6263
}
@@ -6308,13 +6308,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6308
6308
}
6309
6309
6310
6310
TE->setOperandsInOrder();
6311
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i ) {
6311
+ for (unsigned I : seq<unsigned>( 0, VL0->getNumOperands()) ) {
6312
6312
ValueList Operands;
6313
6313
// Prepare the operand vector.
6314
6314
for (Value *V : VL)
6315
- Operands.push_back(cast<Instruction>(V)->getOperand(i ));
6315
+ Operands.push_back(cast<Instruction>(V)->getOperand(I ));
6316
6316
6317
- buildTree_rec(Operands, Depth + 1, {TE, i });
6317
+ buildTree_rec(Operands, Depth + 1, {TE, I });
6318
6318
}
6319
6319
return;
6320
6320
}
@@ -11111,9 +11111,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
11111
11111
// visit every block once.
11112
11112
SmallPtrSet<BasicBlock *, 4> VisitedBBs;
11113
11113
11114
- for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i ) {
11114
+ for (unsigned I : seq<unsigned>( 0, PH->getNumIncomingValues()) ) {
11115
11115
ValueList Operands;
11116
- BasicBlock *IBB = PH->getIncomingBlock(i );
11116
+ BasicBlock *IBB = PH->getIncomingBlock(I );
11117
11117
11118
11118
// Stop emission if all incoming values are generated.
11119
11119
if (NewPhi->getNumIncomingValues() == PH->getNumIncomingValues()) {
@@ -11128,9 +11128,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
11128
11128
11129
11129
Builder.SetInsertPoint(IBB->getTerminator());
11130
11130
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
11131
- Value *Vec = vectorizeOperand(E, i , /*PostponedPHIs=*/true);
11131
+ Value *Vec = vectorizeOperand(E, I , /*PostponedPHIs=*/true);
11132
11132
if (VecTy != Vec->getType()) {
11133
- assert(MinBWs.contains(PH->getIncomingValue(i )) &&
11133
+ assert(MinBWs.contains(PH->getIncomingValue(I )) &&
11134
11134
"Expected item in MinBWs.");
11135
11135
Vec = Builder.CreateIntCast(Vec, VecTy, It->second.second);
11136
11136
}
@@ -11640,27 +11640,27 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
11640
11640
if (isVectorIntrinsicWithOverloadTypeAtArg(IID, -1))
11641
11641
TysForDecl.push_back(
11642
11642
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()) ) {
11644
11644
ValueList OpVL;
11645
11645
// Some intrinsics have scalar arguments. This argument should not be
11646
11646
// vectorized.
11647
- if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, j )) {
11647
+ if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, I )) {
11648
11648
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 ))
11652
11652
TysForDecl.push_back(ScalarArg->getType());
11653
11653
continue;
11654
11654
}
11655
11655
11656
- Value *OpVec = vectorizeOperand(E, j , PostponedPHIs);
11656
+ Value *OpVec = vectorizeOperand(E, I , PostponedPHIs);
11657
11657
if (E->VectorizedValue) {
11658
11658
LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
11659
11659
return E->VectorizedValue;
11660
11660
}
11661
- LLVM_DEBUG(dbgs() << "SLP: OpVec[" << j << "]: " << *OpVec << "\n");
11661
+ LLVM_DEBUG(dbgs() << "SLP: OpVec[" << I << "]: " << *OpVec << "\n");
11662
11662
OpVecs.push_back(OpVec);
11663
- if (isVectorIntrinsicWithOverloadTypeAtArg(IID, j ))
11663
+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, I ))
11664
11664
TysForDecl.push_back(OpVec->getType());
11665
11665
}
11666
11666
@@ -12079,18 +12079,18 @@ Value *BoUpSLP::vectorizeTree(
12079
12079
// Find the insertion point for the extractelement lane.
12080
12080
if (auto *VecI = dyn_cast<Instruction>(Vec)) {
12081
12081
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) {
12084
12084
Instruction *IncomingTerminator =
12085
- PH->getIncomingBlock(i )->getTerminator();
12085
+ PH->getIncomingBlock(I )->getTerminator();
12086
12086
if (isa<CatchSwitchInst>(IncomingTerminator)) {
12087
12087
Builder.SetInsertPoint(VecI->getParent(),
12088
12088
std::next(VecI->getIterator()));
12089
12089
} else {
12090
- Builder.SetInsertPoint(PH->getIncomingBlock(i )->getTerminator());
12090
+ Builder.SetInsertPoint(PH->getIncomingBlock(I )->getTerminator());
12091
12091
}
12092
12092
Value *NewInst = ExtractAndExtendIfNeeded(Vec);
12093
- PH->setOperand(i , NewInst);
12093
+ PH->setOperand(I , NewInst);
12094
12094
}
12095
12095
}
12096
12096
} else {
@@ -16036,41 +16036,41 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
16036
16036
return I->use_empty() &&
16037
16037
(I->getType()->isVoidTy() || isa<CallInst, InvokeInst>(I));
16038
16038
};
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 ) {
16040
16040
// Skip instructions with scalable type. The num of elements is unknown at
16041
16041
// compile-time for scalable type.
16042
- if (isa<ScalableVectorType>(it ->getType()))
16042
+ if (isa<ScalableVectorType>(It ->getType()))
16043
16043
continue;
16044
16044
16045
16045
// Skip instructions marked for the deletion.
16046
- if (R.isDeleted(&*it ))
16046
+ if (R.isDeleted(&*It ))
16047
16047
continue;
16048
16048
// 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())) {
16052
16052
// We would like to start over since some instructions are deleted
16053
16053
// and the iterator may become invalid value.
16054
16054
Changed = true;
16055
- it = BB->begin();
16056
- e = BB->end();
16055
+ It = BB->begin();
16056
+ E = BB->end();
16057
16057
}
16058
16058
continue;
16059
16059
}
16060
16060
16061
- if (isa<DbgInfoIntrinsic>(it ))
16061
+ if (isa<DbgInfoIntrinsic>(It ))
16062
16062
continue;
16063
16063
16064
16064
// Try to vectorize reductions that use PHINodes.
16065
- if (PHINode *P = dyn_cast<PHINode>(it )) {
16065
+ if (PHINode *P = dyn_cast<PHINode>(It )) {
16066
16066
// Check that the PHI is a reduction PHI.
16067
16067
if (P->getNumIncomingValues() == 2) {
16068
16068
// Try to match and vectorize a horizontal reduction.
16069
16069
Instruction *Root = getReductionInstr(DT, P, BB, LI);
16070
16070
if (Root && vectorizeRootInstruction(P, Root, BB, R, TTI)) {
16071
16071
Changed = true;
16072
- it = BB->begin();
16073
- e = BB->end();
16072
+ It = BB->begin();
16073
+ E = BB->end();
16074
16074
continue;
16075
16075
}
16076
16076
}
@@ -16095,9 +16095,9 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
16095
16095
continue;
16096
16096
}
16097
16097
16098
- if (HasNoUsers(&*it )) {
16098
+ if (HasNoUsers(&*It )) {
16099
16099
bool OpsChanged = false;
16100
- auto *SI = dyn_cast<StoreInst>(it );
16100
+ auto *SI = dyn_cast<StoreInst>(It );
16101
16101
bool TryToVectorizeRoot = ShouldStartVectorizeHorAtStore || !SI;
16102
16102
if (SI) {
16103
16103
auto *I = Stores.find(getUnderlyingObject(SI->getPointerOperand()));
@@ -16111,7 +16111,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
16111
16111
SI->getValueOperand()->hasOneUse();
16112
16112
}
16113
16113
if (TryToVectorizeRoot) {
16114
- for (auto *V : it ->operand_values()) {
16114
+ for (auto *V : It ->operand_values()) {
16115
16115
// Postponed instructions should not be vectorized here, delay their
16116
16116
// vectorization.
16117
16117
if (auto *VI = dyn_cast<Instruction>(V);
@@ -16124,21 +16124,21 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
16124
16124
// top-tree instructions to try to vectorize as many instructions as
16125
16125
// possible.
16126
16126
OpsChanged |=
16127
- VectorizeInsertsAndCmps(/*VectorizeCmps=*/it ->isTerminator());
16127
+ VectorizeInsertsAndCmps(/*VectorizeCmps=*/It ->isTerminator());
16128
16128
if (OpsChanged) {
16129
16129
// We would like to start over since some instructions are deleted
16130
16130
// and the iterator may become invalid value.
16131
16131
Changed = true;
16132
- it = BB->begin();
16133
- e = BB->end();
16132
+ It = BB->begin();
16133
+ E = BB->end();
16134
16134
continue;
16135
16135
}
16136
16136
}
16137
16137
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 ));
16142
16142
}
16143
16143
16144
16144
return Changed;
0 commit comments