Skip to content

Commit 5ee789e

Browse files
committed
Add check for VRSUB_VI
1 parent 890f7da commit 5ee789e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,12 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
529529
if (LT.second.isFixedLengthVector())
530530
// vrsub.vi has a 5 bit immediate field, otherwise an li suffices
531531
LenCost = isInt<5>(LT.second.getVectorNumElements() - 1) ? 0 : 1;
532-
InstructionCost GatherCost = getRISCVInstructionCost(
533-
{RISCV::VID_V, RISCV::VRSUB_VX, RISCV::VRGATHER_VV}, LT.second,
534-
CostKind);
532+
unsigned Opcodes[] = {RISCV::VID_V, RISCV::VRSUB_VX, RISCV : VRGATHER_VV};
533+
if (LT.second.isFixedLengthVector() &&
534+
isInt<5>(LT.second.getVectorNumElements() - 1))
535+
Opcodes[1] = RISCV::VRSUB_VI;
536+
InstructionCost GatherCost =
537+
getRISCVInstructionCost(Opcodes, LT.second, CostKind);
535538
// Mask operation additionally required extend and truncate
536539
InstructionCost ExtendCost = Tp->getElementType()->isIntegerTy(1) ? 3 : 0;
537540
return LT.first * (LenCost + GatherCost + ExtendCost);

0 commit comments

Comments
 (0)