[PATCH] D98206: [TTI] Add a Mask to getShuffleCost
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 9 11:12:55 PST 2021
ABataev added inline comments.
================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:1047
/// NOTE: For subvector extractions Tp represents the source type.
- int getShuffleCost(ShuffleKind Kind, VectorType *Tp, int Index = 0,
- VectorType *SubTp = nullptr) const;
+ int getShuffleCost(ShuffleKind Kind, VectorType *Tp, ArrayRef<int> Mask,
+ int Index = 0, VectorType *SubTp = nullptr) const;
----------------
`ArrayRef<int> Mask = llvm::None`? How about make it a param with the default value?
================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:1260
+ TTI::SK_ExtractSubvector, cast<VectorType>(Args[0]->getType()),
+ ArrayRef<int>(), Index, cast<VectorType>(RetTy));
}
----------------
Better to use `llvm::None` here and in the other places
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:294
static Optional<TargetTransformInfo::ShuffleKind>
-isShuffle(ArrayRef<Value *> VL) {
+isShuffle(ArrayRef<Value *> VL, SmallVector<int> &Mask) {
auto *EI0 = cast<ExtractElementInst>(VL[0]);
----------------
`SmalVectorImpl<int> &`?
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:313
+ if (Idx->getValue().uge(Size)) {
+ Mask.push_back(-1);
continue;
----------------
`UndefMaskElem`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3474
+ ReuseShuffleCost = TTI->getShuffleCost(
+ TargetTransformInfo::SK_PermuteSingleSrc, VecTy, ArrayRef<int>());
}
----------------
dmgreen wrote:
> I don't know the SLP vectorizer very well. Could these use E->ReuseShuffleIndices?
I think yes.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3556
CommonCost = TTI->getShuffleCost(
- TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
+ TargetTransformInfo::SK_PermuteSingleSrc, VecTy, ArrayRef<int>());
}
----------------
You can call `inversePermutation` to get a mask out of `E->ReorderIndices`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3782
VecLdCost += TTI->getShuffleCost(
- TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
+ TargetTransformInfo::SK_PermuteSingleSrc, VecTy, ArrayRef<int>());
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecLdCost, ScalarLdCost));
----------------
Same, call `inversePermutation` to get a mask out of `E->ReorderIndices`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3799
VecStCost += TTI->getShuffleCost(
- TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
+ TargetTransformInfo::SK_PermuteSingleSrc, VecTy, ArrayRef<int>());
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecStCost, ScalarStCost));
----------------
Same, call `inversePermutation` to get a mask out of `E->ReorderIndices`
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3867
+ VecCost += TTI->getShuffleCost(TargetTransformInfo::SK_Select, VecTy,
+ ArrayRef<int>(), 0);
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
----------------
The mask here is something like `1010101...`, just in case
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98206/new/
https://reviews.llvm.org/D98206
More information about the llvm-commits
mailing list