[PATCH] D98714: [SLP] Add insertelement instructions to vectorizable tree
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 14:12:58 PDT 2021
ABataev added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2846-2847
+
+ for (auto *V : VL)
+ MinIndex = std::min(MinIndex, int(GetConstantOperand(V)));
+
----------------
```
for (Value *V : VL)
MinIndex = std::min<int>(MinIndex, GetConstantOperand(V));
```
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3643-3644
+ for (auto *V : VL) {
+ int Index = cast<ConstantInt>(cast<InsertElementInst>(V)->getOperand(2))
+ ->getZExtValue();
+ DemandedElts.setBit(Index);
----------------
Turn `GetConstantOperand` into a function and use it
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4197
+ if (auto *Insert = dyn_cast<InsertElementInst>(EU.Scalar)) {
+ auto &ScalarsList = getTreeEntry(EU.Scalar)->Scalars;
+ ValueSet Scalars(ScalarsList.begin(), ScalarsList.end());
----------------
`ArrayRef<Value *>`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4202
+
+ for (auto *S : Scalars)
+ MinIndex = std::min(
----------------
`Value *`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4203-4206
+ MinIndex = std::min(
+ MinIndex,
+ int(cast<ConstantInt>(cast<InsertElementInst>(S)->getOperand(2))
+ ->getZExtValue()));
----------------
`std::min<int>` and use a function
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4211-4212
+ int Index =
+ cast<ConstantInt>(cast<InsertElementInst>(Insert)->getOperand(2))
+ ->getZExtValue() -
+ MinIndex;
----------------
Use a function to extract index
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4217
+ NumInsertsUsed++;
+ } while (is_contained(Scalars, Insert));
+
----------------
`Scalars.contains(Insert)` or `.count(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