Skip to content

Commit 84f24c2

Browse files
authored
[RISCV][TTI] Scale the cost of intrinsic umin/umax/smin/smax with LMUL (#87245)
Use the return type to measure the LMUL size for throughput/latency cost
1 parent f33a6dc commit 84f24c2

File tree

2 files changed

+80
-62
lines changed

2 files changed

+80
-62
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,27 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
810810
case Intrinsic::smin:
811811
case Intrinsic::smax: {
812812
auto LT = getTypeLegalizationCost(RetTy);
813-
if ((ST->hasVInstructions() && LT.second.isVector()) ||
814-
(LT.second.isScalarInteger() && ST->hasStdExtZbb()))
813+
if (LT.second.isScalarInteger() && ST->hasStdExtZbb())
815814
return LT.first;
815+
816+
if (ST->hasVInstructions() && LT.second.isVector()) {
817+
unsigned Op;
818+
switch (ICA.getID()) {
819+
case Intrinsic::umin:
820+
Op = RISCV::VMINU_VV;
821+
break;
822+
case Intrinsic::umax:
823+
Op = RISCV::VMAXU_VV;
824+
break;
825+
case Intrinsic::smin:
826+
Op = RISCV::VMIN_VV;
827+
break;
828+
case Intrinsic::smax:
829+
Op = RISCV::VMAX_VV;
830+
break;
831+
}
832+
return LT.first * getRISCVInstructionCost(Op, LT.second, CostKind);
833+
}
816834
break;
817835
}
818836
case Intrinsic::sadd_sat:

0 commit comments

Comments
 (0)