[PATCH] D98714: [SLP] Add insertelement instructions to vectorizable tree
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 6 05:06:14 PDT 2021
ABataev added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4670-4671
+ // Create shuffle to resize vector
+ for (unsigned I = 0; I < NumElts; I++)
+ Mask[I] = (I < NumScalars) ? I : UndefMaskElem;
+ V = Builder.CreateShuffleVector(V, UndefValue::get(V->getType()), Mask);
----------------
```
SmallVector<int, 16> Mask(NumElts, UndefMaskElem);
std::iota(Mask.begin(), std::next(Mask.begin(), NumScalars), 0);
```
Also, I think just `std::iota(Mask.begin(), Mask.end(), 0); ` shall work too
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4672-4680
+ V = Builder.CreateShuffleVector(V, UndefValue::get(V->getType()), Mask);
+
+ for (unsigned I = 0; I < NumElts; I++)
+ Mask[I] =
+ (I < MinIndex || I >= MaxIndex) ? I : NumElts - MinIndex + I;
+
+ V = Builder.CreateShuffleVector(
----------------
Can we use `ShuffleBuilder` here?
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4672-4680
+ V = Builder.CreateShuffleVector(V, UndefValue::get(V->getType()), Mask);
+
+ for (unsigned I = 0; I < NumElts; I++)
+ Mask[I] =
+ (I < MinIndex || I >= MaxIndex) ? I : NumElts - MinIndex + I;
+
+ V = Builder.CreateShuffleVector(
----------------
ABataev wrote:
> Can we use `ShuffleBuilder` here?
Did you include these costs in the cost model?
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5183
+ NumInsertsUsed++;
+ } while (is_contained(Scalars, Insert));
+
----------------
`Scalars.contain(Insert)`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98714/new/
https://reviews.llvm.org/D98714
More information about the llvm-commits
mailing list