Skip to content

Commit b5c7bc2

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

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
@@ -481,7 +481,6 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
481481
ArrayRef<const Value *> Args,
482482
const Instruction *CxtI) {
483483
Kind = improveShuffleKindFromMask(Kind, Mask, Tp, Index, SubTp);
484-
485484
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Tp);
486485

487486
// First, handle cases where having a fixed length vector enables us to
@@ -889,11 +888,12 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
889888
if (Opcode == Instruction::Load) {
890889
InstructionCost Cost = MemCost;
891890
for (unsigned Index : Indices) {
892-
FixedVectorType *SubVecTy =
891+
FixedVectorType *VecTy =
893892
FixedVectorType::get(FVTy->getElementType(), VF * Factor);
894893
auto Mask = createStrideMask(Index, Factor, VF);
894+
Mask.resize(VF * Factor, -1);
895895
InstructionCost ShuffleCost =
896-
getShuffleCost(TTI::ShuffleKind::SK_PermuteSingleSrc, SubVecTy, Mask,
896+
getShuffleCost(TTI::ShuffleKind::SK_PermuteSingleSrc, VecTy, Mask,
897897
CostKind, 0, nullptr, {});
898898
Cost += ShuffleCost;
899899
}

0 commit comments

Comments
 (0)