[llvm] [RISCV][TTI]Use processShuffleMasks for cost estimations/actual per-register shuffles (PR #118103)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 24 09:29:24 PST 2024
================
@@ -388,7 +388,109 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
// First, handle cases where having a fixed length vector enables us to
// give a more accurate cost than falling back to generic scalable codegen.
// TODO: Each of these cases hints at a modeling gap around scalable vectors.
- if (isa<FixedVectorType>(Tp)) {
+ if (ST->hasVInstructions() && isa<FixedVectorType>(Tp)) {
+ MVT LegalVT = LT.second;
+ InstructionCost NumOfDests = InstructionCost::getInvalid();
+ const auto VLen = ST->getRealVLen();
+ if (VLen && LegalVT.isFixedLengthVector() && !Mask.empty()) {
+ MVT ElemVT = LegalVT.getVectorElementType();
+ unsigned ElemsPerVReg = *VLen / ElemVT.getFixedSizeInBits();
+ LegalVT = getTypeLegalizationCost(
+ FixedVectorType::get(Tp->getElementType(), ElemsPerVReg))
+ .second;
+ NumOfDests = divideCeil(Mask.size(), LegalVT.getVectorNumElements());
+ }
+ if (NumOfDests.isValid() && NumOfDests > 1 &&
+ LegalVT.isFixedLengthVector() &&
+ LegalVT.getVectorElementType().getSizeInBits() ==
+ Tp->getElementType()->getPrimitiveSizeInBits() &&
+ LegalVT.getVectorNumElements() <
+ Tp->getElementCount().getFixedValue()) {
+ unsigned VecTySize = DL.getTypeStoreSize(Tp);
+ unsigned LegalVTSize = LegalVT.getStoreSize();
+ // Number of source vectors after legalization:
+ unsigned NumOfSrcs = divideCeil(VecTySize, LegalVTSize);
+ // Number of destination vectors after legalization:
----------------
alexey-bataev wrote:
Yes, fixed
https://github.com/llvm/llvm-project/pull/118103
More information about the llvm-commits
mailing list