[PATCH] D99719: [SLP] Better estimate cost of no-op extracts on target vectors.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 1 07:16:18 PDT 2021
fhahn marked an inline comment as done.
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3495-3498
+ unsigned MaxVecRegSize = getMaxVecRegSize();
+ unsigned EltSize = getVectorElementSize(VL[0]);
+ unsigned EltsPerVector = MaxVecRegSize / EltSize;
+ unsigned Idx = 0;
----------------
ABataev wrote:
> I think it is better to use `TLI->getTypeLegalizationCost(DL, cast<ExtractElementInst>(V)->getVectorOperandType());` to get the real machine vector type and the number of splits.
I think using `TargetLoweringInfo` would indeed be better, but unfortunately I don't think we can access it here, as it is defined in CodeGen? I tried to see if there are any other such uses in `llvm/lib/Transforms` but couldn't. Perhaps there's a way to use it I am missing?
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3535
+ Cost -= TTI->getVectorInstrCost(Instruction::ExtractElement,
+ VecTy, I);
+ }
----------------
ABataev wrote:
> I think you need to use the real extract indices here to be more correct, i.e.
> ```
> for (unsigned I = Idx - EltsPerVector; I <= Idx; ++I)
> Cost -= TTI->getVectorInstrCost(Instruction::ExtractElement,
> cast<ExtractElementInst>(VL[I])->getVectorOperandType(), *getExtractIndex(cast<Instruction>(VL[I])));
> ```
Thanks, I think that's much better, updated.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99719/new/
https://reviews.llvm.org/D99719
More information about the llvm-commits
mailing list