Skip to content

Commit 487b43c

Browse files
authored
[RISCV] Pass subvector type to isLegalInterleavedAccessType in getInterleavedMemoryOpCost. (llvm#91825)
isLegalInterleavedAccessType expects the subvector type, but getInterleavedMemoryOpCost is called with the full vector type. So we need to divide by Factor.
1 parent f2d7400 commit 487b43c

File tree

3 files changed

+259
-330
lines changed

3 files changed

+259
-330
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,19 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
613613
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(VTy);
614614
// Need to make sure type has't been scalarized
615615
if (LT.second.isVector()) {
616-
auto *LegalVTy = VectorType::get(VTy->getElementType(),
617-
LT.second.getVectorElementCount());
618-
// FIXME: We use the memory op cost of the *legalized* type here, becuase
619-
// it's getMemoryOpCost returns a really expensive cost for types like
620-
// <6 x i8>, which show up when doing interleaves of Factor=3 etc.
621-
// Should the memory op cost of these be cheaper?
622-
if (TLI->isLegalInterleavedAccessType(LegalVTy, Factor, Alignment,
616+
auto *SubVecTy =
617+
VectorType::get(VTy->getElementType(),
618+
VTy->getElementCount().divideCoefficientBy(Factor));
619+
620+
if (VTy->getElementCount().isKnownMultipleOf(Factor) &&
621+
TLI->isLegalInterleavedAccessType(SubVecTy, Factor, Alignment,
623622
AddressSpace, DL)) {
623+
// FIXME: We use the memory op cost of the *legalized* type here,
624+
// because it's getMemoryOpCost returns a really expensive cost for
625+
// types like <6 x i8>, which show up when doing interleaves of
626+
// Factor=3 etc. Should the memory op cost of these be cheaper?
627+
auto *LegalVTy = VectorType::get(VTy->getElementType(),
628+
LT.second.getVectorElementCount());
624629
InstructionCost LegalMemCost = getMemoryOpCost(
625630
Opcode, LegalVTy, Alignment, AddressSpace, CostKind);
626631
return LT.first + LegalMemCost;

0 commit comments

Comments
 (0)