[PATCH] D124769: [SLP] AdjustExtractsCost - remove redundant subvector extraction code
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 06:33:31 PDT 2022
RKSimon created this revision.
RKSimon added reviewers: ABataev, Vasilis, reames.
Herald added subscribers: vporpo, hiraditya.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: LLVM.
I noticed this while investigating replacing the getVectorInstrCost(Instruction::ExtractElement) calls with getScalarizationOverhead instead.
This code should be helping improve the costs of extracting an element from subvectors created during legalization, but removing it seems to have no effect - I'm guessing the getVectorInstrCost/getScalarizationOverhead improvements may have made it redundant?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124769
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5189,7 +5189,6 @@
TargetTransformInfo &TTIRef = *TTI;
auto &&AdjustExtractsCost = [this, &TTIRef, CostKind, VL, VecTy,
VectorizedVals, E](InstructionCost &Cost) {
- DenseMap<Value *, int> ExtractVectorsTys;
SmallPtrSet<Value *, 4> CheckedExtracts;
for (auto *V : VL) {
if (isa<UndefValue>(V))
@@ -5210,12 +5209,6 @@
if (!EEIdx)
continue;
unsigned Idx = *EEIdx;
- if (TTIRef.getNumberOfParts(VecTy) !=
- TTIRef.getNumberOfParts(EE->getVectorOperandType())) {
- auto It =
- ExtractVectorsTys.try_emplace(EE->getVectorOperand(), Idx).first;
- It->getSecond() = std::min<int>(It->second, Idx);
- }
// Take credit for instruction that will become dead.
if (EE->hasOneUse()) {
Instruction *Ext = EE->user_back();
@@ -5237,34 +5230,6 @@
Cost -= TTIRef.getVectorInstrCost(Instruction::ExtractElement,
EE->getVectorOperandType(), Idx);
}
- // Add a cost for subvector extracts/inserts if required.
- for (const auto &Data : ExtractVectorsTys) {
- auto *EEVTy = cast<FixedVectorType>(Data.first->getType());
- unsigned NumElts = VecTy->getNumElements();
- if (Data.second % NumElts == 0)
- continue;
- if (TTIRef.getNumberOfParts(EEVTy) > TTIRef.getNumberOfParts(VecTy)) {
- unsigned Idx = (Data.second / NumElts) * NumElts;
- unsigned EENumElts = EEVTy->getNumElements();
- if (Idx + NumElts <= EENumElts) {
- Cost +=
- TTIRef.getShuffleCost(TargetTransformInfo::SK_ExtractSubvector,
- EEVTy, None, Idx, VecTy);
- } else {
- // Need to round up the subvector type vectorization factor to avoid a
- // crash in cost model functions. Make SubVT so that Idx + VF of SubVT
- // <= EENumElts.
- auto *SubVT =
- FixedVectorType::get(VecTy->getElementType(), EENumElts - Idx);
- Cost +=
- TTIRef.getShuffleCost(TargetTransformInfo::SK_ExtractSubvector,
- EEVTy, None, Idx, SubVT);
- }
- } else {
- Cost += TTIRef.getShuffleCost(TargetTransformInfo::SK_InsertSubvector,
- VecTy, None, 0, EEVTy);
- }
- }
};
if (E->State == TreeEntry::NeedToGather) {
if (allConstant(VL))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124769.426397.patch
Type: text/x-patch
Size: 2685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220502/6c6a1280/attachment-0001.bin>
More information about the llvm-commits
mailing list