Skip to content

Commit 62be3d6

Browse files
committed
Separate the cost of VRSUB_VI and VRSUB_VX for SK_Reverse
1 parent 890f7da commit 62be3d6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,19 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
526526
// vrsub.vx v10, v9, a0
527527
// vrgather.vv v9, v8, v10
528528
InstructionCost LenCost = 3;
529-
if (LT.second.isFixedLengthVector())
529+
InstructionCost GatherCost;
530+
if (LT.second.isFixedLengthVector()) {
530531
// vrsub.vi has a 5 bit immediate field, otherwise an li suffices
531532
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);
533+
GatherCost = getRISCVInstructionCost(
534+
{RISCV::VID_V, RISCV::VRSUB_VI, RISCV::VRGATHER_VV}, LT.second,
535+
CostKind);
536+
} else {
537+
LenCost = 3;
538+
GatherCost = getRISCVInstructionCost(
539+
{RISCV::VID_V, RISCV::VRSUB_VX, RISCV::VRGATHER_VV}, LT.second,
540+
CostKind);
541+
}
535542
// Mask operation additionally required extend and truncate
536543
InstructionCost ExtendCost = Tp->getElementType()->isIntegerTy(1) ? 3 : 0;
537544
return LT.first * (LenCost + GatherCost + ExtendCost);

0 commit comments

Comments
 (0)