-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SLP] Collect candidate VFs in vector in vectorizeStores (NFC). #82793
Conversation
This is in preparation for #77790 and makes it easy to add other, non-power-of-2 VFs for processing.
@llvm/pr-subscribers-llvm-transforms Author: Florian Hahn (fhahn) ChangesThis is in preparation for Full diff: https://github.com/llvm/llvm-project/pull/82793.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index de4e56ff80659a..8ee840e97e94b7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13918,10 +13918,14 @@ bool SLPVectorizerPass::vectorizeStores(ArrayRef<StoreInst *> Stores,
<< "MinVF (" << MinVF << ")\n");
}
- // FIXME: Is division-by-2 the correct step? Should we assert that the
- // register size is a power-of-2?
- unsigned StartIdx = 0;
+ SmallVector<unsigned> CandidateVFs;
for (unsigned Size = MaxVF; Size >= MinVF; Size /= 2) {
+ // FIXME: Is division-by-2 the correct step? Should we assert that the
+ // register size is a power-of-2?
+ CandidateVFs.push_back(Size);
+ }
+ unsigned StartIdx = 0;
+ for (unsigned Size : CandidateVFs) {
for (unsigned Cnt = StartIdx, E = Operands.size(); Cnt + Size <= E;) {
ArrayRef<Value *> Slice = ArrayRef(Operands).slice(Cnt, Size);
assert(
|
// register size is a power-of-2? | ||
unsigned StartIdx = 0; | ||
SmallVector<unsigned> CandidateVFs; | ||
for (unsigned Size = MaxVF; Size >= MinVF; Size /= 2) { | ||
// FIXME: Is division-by-2 the correct step? Should we assert that the | ||
// register size is a power-of-2? | ||
CandidateVFs.push_back(Size); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// register size is a power-of-2? | |
unsigned StartIdx = 0; | |
SmallVector<unsigned> CandidateVFs; | |
for (unsigned Size = MaxVF; Size >= MinVF; Size /= 2) { | |
// FIXME: Is division-by-2 the correct step? Should we assert that the | |
// register size is a power-of-2? | |
CandidateVFs.push_back(Size); | |
} | |
unsigned Sz = MaxVF / MinVF; | |
SmallVector<unsigned> CandidateVFs(Sz); | |
// FIXME: Is division-by-2 the correct step? Should we assert that the | |
// register size is a power-of-2? | |
unsigned Size = MaxVF; | |
for_each(Candidate, [&](unsigned &VF) { VF = Size; Size /= 2; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted, but needed to use unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
and introduce early exit #83283 so we don't need to handle the case where. MaxVF < MinVF.
Exit early if MaxVF < MinVF. In that case, the loop body below will never get entered. Note that this adjusts the condition from MaxVF <= MinVF. If MaxVF == MinVF, vectorization may still be feasible (and the loop below gets entered).
… users/fhahn/slp-store-vfs-in-vector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
This is in preparation for
#77790 and makes it easy to add other, non-power-of-2 VFs for processing.