[llvm] [RISCV][TTI] Implement vector costs for `llvm.fpto{u|s}i.sat()`. (PR #143655)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 00:37:41 PDT 2025
================
@@ -1541,6 +1541,32 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
cast<VectorType>(ICA.getArgTypes()[0]), {}, CostKind,
0, cast<VectorType>(ICA.getReturnType()));
}
+ case Intrinsic::fptoui_sat:
+ case Intrinsic::fptosi_sat: {
+ InstructionCost Cost = 0;
+ bool IsSigned = ICA.getID() == Intrinsic::fptosi_sat;
+ Type *SrcTy = ICA.getArgTypes()[0];
+
+ auto SrcLT = getTypeLegalizationCost(SrcTy);
+ auto DstLT = getTypeLegalizationCost(RetTy);
+ if (!SrcTy->isVectorTy())
+ break;
+
+ if (!SrcLT.first.isValid() || !DstLT.first.isValid())
+ return InstructionCost::getInvalid();
+
+ Cost +=
+ getCastInstrCost(IsSigned ? Instruction::FPToSI : Instruction::FPToUI,
+ RetTy, SrcTy, TTI::CastContextHint::None, CostKind);
+ if (IsSigned) {
----------------
ElvisWang123 wrote:
Yes, I used the really old version (which is wrong) to show the asm. 😢
Updated, thanks!
https://github.com/llvm/llvm-project/pull/143655
More information about the llvm-commits
mailing list