Skip to content

Commit 8747736

Browse files
[SLP] NFC: Simplify CandidateVFs initialization (#144882)
Also adds a comment to clarify the meaning of MaxRegVF.
1 parent b6b8fa3 commit 8747736

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21198,7 +21198,11 @@ bool SLPVectorizerPass::vectorizeStores(
2119821198
}
2119921199
}
2120021200

21201+
// MaxRegVF represents the number of instructions (scalar, or vector in
21202+
// case of revec) that can be vectorized to naturally fit in a vector
21203+
// register.
2120121204
unsigned MaxRegVF = MaxVF;
21205+
2120221206
MaxVF = std::min<unsigned>(MaxVF, bit_floor(Operands.size()));
2120321207
if (MaxVF < MinVF) {
2120421208
LLVM_DEBUG(dbgs() << "SLP: Vectorization infeasible as MaxVF (" << MaxVF
@@ -21207,13 +21211,11 @@ bool SLPVectorizerPass::vectorizeStores(
2120721211
continue;
2120821212
}
2120921213

21210-
unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
21211-
SmallVector<unsigned> CandidateVFs(Sz + (NonPowerOf2VF > 0 ? 1 : 0));
21212-
unsigned Size = MinVF;
21213-
for (unsigned &VF : reverse(CandidateVFs)) {
21214-
VF = Size > MaxVF ? NonPowerOf2VF : Size;
21215-
Size *= 2;
21216-
}
21214+
SmallVector<unsigned> CandidateVFs;
21215+
for (unsigned VF = std::max(MaxVF, NonPowerOf2VF); VF >= MinVF;
21216+
VF = divideCeil(VF, 2))
21217+
CandidateVFs.push_back(VF);
21218+
2121721219
unsigned End = Operands.size();
2121821220
unsigned Repeat = 0;
2121921221
constexpr unsigned MaxAttempts = 4;

0 commit comments

Comments
 (0)