Skip to content

Commit 1bd13bc

Browse files
authored
[RISCV][TTI] Fix a misuse of the getShuffleCost API [NFC] (#129137)
The getShuffleCost api, in concept, expects to only deal with non-length changing shuffles. We were failing to extend the mask appropriately before invoking it. This came up in #128537 in discussion of a potential invariant, but is otherwise unrelated.
1 parent 1b622a4 commit 1bd13bc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
482482
ArrayRef<const Value *> Args,
483483
const Instruction *CxtI) {
484484
Kind = improveShuffleKindFromMask(Kind, Mask, Tp, Index, SubTp);
485-
486485
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Tp);
487486

488487
// First, handle cases where having a fixed length vector enables us to
@@ -890,11 +889,12 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
890889
if (Opcode == Instruction::Load) {
891890
InstructionCost Cost = MemCost;
892891
for (unsigned Index : Indices) {
893-
FixedVectorType *SubVecTy =
892+
FixedVectorType *VecTy =
894893
FixedVectorType::get(FVTy->getElementType(), VF * Factor);
895894
auto Mask = createStrideMask(Index, Factor, VF);
895+
Mask.resize(VF * Factor, -1);
896896
InstructionCost ShuffleCost =
897-
getShuffleCost(TTI::ShuffleKind::SK_PermuteSingleSrc, SubVecTy, Mask,
897+
getShuffleCost(TTI::ShuffleKind::SK_PermuteSingleSrc, VecTy, Mask,
898898
CostKind, 0, nullptr, {});
899899
Cost += ShuffleCost;
900900
}

0 commit comments

Comments
 (0)