[llvm] badec9b - [SLP][NFC]Fix loops variables names, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 10:35:07 PST 2023
Author: Alexey Bataev
Date: 2023-11-28T10:30:19-08:00
New Revision: badec9b7bfb6fb27d8be42d1b71bea7a3cd37da6
URL: https://github.com/llvm/llvm-project/commit/badec9b7bfb6fb27d8be42d1b71bea7a3cd37da6
DIFF: https://github.com/llvm/llvm-project/commit/badec9b7bfb6fb27d8be42d1b71bea7a3cd37da6.diff
LOG: [SLP][NFC]Fix loops variables names, NFC.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index bf4c25210f225ce..e6ac4c9024f2287 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6065,13 +6065,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n");
TE->setOperandsInOrder();
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i) {
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
ValueList Operands;
// Prepare the operand vector.
for (Value *V : VL)
- Operands.push_back(cast<Instruction>(V)->getOperand(i));
+ Operands.push_back(cast<Instruction>(V)->getOperand(I));
- buildTree_rec(Operands, Depth + 1, {TE, i});
+ buildTree_rec(Operands, Depth + 1, {TE, I});
}
return;
}
@@ -6145,13 +6145,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
TE->setOperandsInOrder();
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i) {
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
ValueList Operands;
// Prepare the operand vector.
for (Value *V : VL)
- Operands.push_back(cast<Instruction>(V)->getOperand(i));
+ Operands.push_back(cast<Instruction>(V)->getOperand(I));
- buildTree_rec(Operands, Depth + 1, {TE, i});
+ buildTree_rec(Operands, Depth + 1, {TE, I});
}
return;
}
@@ -6246,18 +6246,18 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
ReuseShuffleIndicies);
TE->setOperandsInOrder();
- for (unsigned i = 0, e = CI->arg_size(); i != e; ++i) {
+ for (unsigned I : seq<unsigned>(0, CI->arg_size())) {
// For scalar operands no need to create an entry since no need to
// vectorize it.
- if (isVectorIntrinsicWithScalarOpAtArg(ID, i))
+ if (isVectorIntrinsicWithScalarOpAtArg(ID, I))
continue;
ValueList Operands;
// Prepare the operand vector.
for (Value *V : VL) {
auto *CI2 = cast<CallInst>(V);
- Operands.push_back(CI2->getArgOperand(i));
+ Operands.push_back(CI2->getArgOperand(I));
}
- buildTree_rec(Operands, Depth + 1, {TE, i});
+ buildTree_rec(Operands, Depth + 1, {TE, I});
}
return;
}
@@ -6308,13 +6308,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
TE->setOperandsInOrder();
- for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i) {
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
ValueList Operands;
// Prepare the operand vector.
for (Value *V : VL)
- Operands.push_back(cast<Instruction>(V)->getOperand(i));
+ Operands.push_back(cast<Instruction>(V)->getOperand(I));
- buildTree_rec(Operands, Depth + 1, {TE, i});
+ buildTree_rec(Operands, Depth + 1, {TE, I});
}
return;
}
@@ -11111,9 +11111,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
// visit every block once.
SmallPtrSet<BasicBlock *, 4> VisitedBBs;
- for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i) {
+ for (unsigned I : seq<unsigned>(0, PH->getNumIncomingValues())) {
ValueList Operands;
- BasicBlock *IBB = PH->getIncomingBlock(i);
+ BasicBlock *IBB = PH->getIncomingBlock(I);
// Stop emission if all incoming values are generated.
if (NewPhi->getNumIncomingValues() == PH->getNumIncomingValues()) {
@@ -11128,9 +11128,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Builder.SetInsertPoint(IBB->getTerminator());
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
- Value *Vec = vectorizeOperand(E, i, /*PostponedPHIs=*/true);
+ Value *Vec = vectorizeOperand(E, I, /*PostponedPHIs=*/true);
if (VecTy != Vec->getType()) {
- assert(MinBWs.contains(PH->getIncomingValue(i)) &&
+ assert(MinBWs.contains(PH->getIncomingValue(I)) &&
"Expected item in MinBWs.");
Vec = Builder.CreateIntCast(Vec, VecTy, It->second.second);
}
@@ -11640,27 +11640,27 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
if (isVectorIntrinsicWithOverloadTypeAtArg(IID, -1))
TysForDecl.push_back(
FixedVectorType::get(CI->getType(), E->Scalars.size()));
- for (int j = 0, e = CI->arg_size(); j < e; ++j) {
+ for (unsigned I : seq<unsigned>(0, CI->arg_size())) {
ValueList OpVL;
// Some intrinsics have scalar arguments. This argument should not be
// vectorized.
- if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, j)) {
+ if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(IID, I)) {
CallInst *CEI = cast<CallInst>(VL0);
- ScalarArg = CEI->getArgOperand(j);
- OpVecs.push_back(CEI->getArgOperand(j));
- if (isVectorIntrinsicWithOverloadTypeAtArg(IID, j))
+ ScalarArg = CEI->getArgOperand(I);
+ OpVecs.push_back(CEI->getArgOperand(I));
+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, I))
TysForDecl.push_back(ScalarArg->getType());
continue;
}
- Value *OpVec = vectorizeOperand(E, j, PostponedPHIs);
+ Value *OpVec = vectorizeOperand(E, I, PostponedPHIs);
if (E->VectorizedValue) {
LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
return E->VectorizedValue;
}
- LLVM_DEBUG(dbgs() << "SLP: OpVec[" << j << "]: " << *OpVec << "\n");
+ LLVM_DEBUG(dbgs() << "SLP: OpVec[" << I << "]: " << *OpVec << "\n");
OpVecs.push_back(OpVec);
- if (isVectorIntrinsicWithOverloadTypeAtArg(IID, j))
+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, I))
TysForDecl.push_back(OpVec->getType());
}
@@ -12079,18 +12079,18 @@ Value *BoUpSLP::vectorizeTree(
// Find the insertion point for the extractelement lane.
if (auto *VecI = dyn_cast<Instruction>(Vec)) {
if (PHINode *PH = dyn_cast<PHINode>(User)) {
- for (int i = 0, e = PH->getNumIncomingValues(); i != e; ++i) {
- if (PH->getIncomingValue(i) == Scalar) {
+ for (unsigned I : seq<unsigned>(0, PH->getNumIncomingValues())) {
+ if (PH->getIncomingValue(I) == Scalar) {
Instruction *IncomingTerminator =
- PH->getIncomingBlock(i)->getTerminator();
+ PH->getIncomingBlock(I)->getTerminator();
if (isa<CatchSwitchInst>(IncomingTerminator)) {
Builder.SetInsertPoint(VecI->getParent(),
std::next(VecI->getIterator()));
} else {
- Builder.SetInsertPoint(PH->getIncomingBlock(i)->getTerminator());
+ Builder.SetInsertPoint(PH->getIncomingBlock(I)->getTerminator());
}
Value *NewInst = ExtractAndExtendIfNeeded(Vec);
- PH->setOperand(i, NewInst);
+ PH->setOperand(I, NewInst);
}
}
} else {
@@ -16036,41 +16036,41 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
return I->use_empty() &&
(I->getType()->isVoidTy() || isa<CallInst, InvokeInst>(I));
};
- for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) {
+ for (BasicBlock::iterator It = BB->begin(), E = BB->end(); It != E; ++It) {
// Skip instructions with scalable type. The num of elements is unknown at
// compile-time for scalable type.
- if (isa<ScalableVectorType>(it->getType()))
+ if (isa<ScalableVectorType>(It->getType()))
continue;
// Skip instructions marked for the deletion.
- if (R.isDeleted(&*it))
+ if (R.isDeleted(&*It))
continue;
// We may go through BB multiple times so skip the one we have checked.
- if (!VisitedInstrs.insert(&*it).second) {
- if (HasNoUsers(&*it) &&
- VectorizeInsertsAndCmps(/*VectorizeCmps=*/it->isTerminator())) {
+ if (!VisitedInstrs.insert(&*It).second) {
+ if (HasNoUsers(&*It) &&
+ VectorizeInsertsAndCmps(/*VectorizeCmps=*/It->isTerminator())) {
// We would like to start over since some instructions are deleted
// and the iterator may become invalid value.
Changed = true;
- it = BB->begin();
- e = BB->end();
+ It = BB->begin();
+ E = BB->end();
}
continue;
}
- if (isa<DbgInfoIntrinsic>(it))
+ if (isa<DbgInfoIntrinsic>(It))
continue;
// Try to vectorize reductions that use PHINodes.
- if (PHINode *P = dyn_cast<PHINode>(it)) {
+ if (PHINode *P = dyn_cast<PHINode>(It)) {
// Check that the PHI is a reduction PHI.
if (P->getNumIncomingValues() == 2) {
// Try to match and vectorize a horizontal reduction.
Instruction *Root = getReductionInstr(DT, P, BB, LI);
if (Root && vectorizeRootInstruction(P, Root, BB, R, TTI)) {
Changed = true;
- it = BB->begin();
- e = BB->end();
+ It = BB->begin();
+ E = BB->end();
continue;
}
}
@@ -16095,9 +16095,9 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
continue;
}
- if (HasNoUsers(&*it)) {
+ if (HasNoUsers(&*It)) {
bool OpsChanged = false;
- auto *SI = dyn_cast<StoreInst>(it);
+ auto *SI = dyn_cast<StoreInst>(It);
bool TryToVectorizeRoot = ShouldStartVectorizeHorAtStore || !SI;
if (SI) {
auto *I = Stores.find(getUnderlyingObject(SI->getPointerOperand()));
@@ -16111,7 +16111,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
SI->getValueOperand()->hasOneUse();
}
if (TryToVectorizeRoot) {
- for (auto *V : it->operand_values()) {
+ for (auto *V : It->operand_values()) {
// Postponed instructions should not be vectorized here, delay their
// vectorization.
if (auto *VI = dyn_cast<Instruction>(V);
@@ -16124,21 +16124,21 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
// top-tree instructions to try to vectorize as many instructions as
// possible.
OpsChanged |=
- VectorizeInsertsAndCmps(/*VectorizeCmps=*/it->isTerminator());
+ VectorizeInsertsAndCmps(/*VectorizeCmps=*/It->isTerminator());
if (OpsChanged) {
// We would like to start over since some instructions are deleted
// and the iterator may become invalid value.
Changed = true;
- it = BB->begin();
- e = BB->end();
+ It = BB->begin();
+ E = BB->end();
continue;
}
}
- if (isa<InsertElementInst, InsertValueInst>(it))
- PostProcessInserts.insert(&*it);
- else if (isa<CmpInst>(it))
- PostProcessCmps.insert(cast<CmpInst>(&*it));
+ if (isa<InsertElementInst, InsertValueInst>(It))
+ PostProcessInserts.insert(&*It);
+ else if (isa<CmpInst>(It))
+ PostProcessCmps.insert(cast<CmpInst>(&*It));
}
return Changed;
More information about the llvm-commits
mailing list