Skip to content

Commit f346cbd

Browse files
committed
[RISCV][TTI] Factor out getVRGatherVICost helper [nfc]
Reasonable implementations may differ in complexity cost, so doing some API prepwork to support tunables.
1 parent 9e66ea5 commit f346cbd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ InstructionCost RISCVTTIImpl::getVRGatherVVCost(MVT VT) {
270270
return getLMULCost(VT) * getLMULCost(VT);
271271
}
272272

273+
/// Return the cost of a vrgather.vi (or vx) instruction for the type VT.
274+
/// vrgather.vi/vx may be linear in the number of vregs implied by LMUL,
275+
/// or may track the vrgather.vv cost. It is implementation-dependent.
276+
InstructionCost RISCVTTIImpl::getVRGatherVICost(MVT VT) {
277+
return getLMULCost(VT);
278+
}
279+
273280
InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
274281
VectorType *Tp, ArrayRef<int> Mask,
275282
TTI::TargetCostKind CostKind,
@@ -436,9 +443,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
436443

437444
// Example sequence:
438445
// vrgather.vi v9, v8, 0
439-
// TODO: vrgather could be slower than vmv.v.x. It is
440-
// implementation-dependent.
441-
return LT.first * getLMULCost(LT.second);
446+
return LT.first * getVRGatherVICost(LT.second);
442447
}
443448
case TTI::SK_Splice:
444449
// vslidedown+vslideup.

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
124124
}
125125

126126
InstructionCost getVRGatherVVCost(MVT VT);
127+
InstructionCost getVRGatherVICost(MVT VT);
127128

128129
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
129130
ArrayRef<int> Mask,

0 commit comments

Comments
 (0)