[llvm] [RISCV][TTI] Clarify getRISCVInstructionCost usage and fix MVT for ISD::FP_EXTEND (PR #121556)
Shih-Po Hung via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 3 23:21:57 PST 2025
================
@@ -1301,13 +1301,16 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
: RISCV::VFNCVT_F_F_W;
InstructionCost Cost = 0;
for (; SrcEltSize != DstEltSize;) {
- MVT ElementMVT = (ISD == ISD::TRUNCATE)
- ? MVT::getIntegerVT(DstEltSize)
+ MVT ElementMVT = (ISD == ISD::TRUNCATE) ? MVT::getIntegerVT(DstEltSize)
+ : (ISD == ISD::FP_EXTEND)
+ ? MVT::getFloatingPointVT(SrcEltSize)
: MVT::getFloatingPointVT(DstEltSize);
- MVT DstMVT = DstLT.second.changeVectorElementType(ElementMVT);
- DstEltSize =
- (DstEltSize > SrcEltSize) ? DstEltSize >> 1 : DstEltSize << 1;
- Cost += getRISCVInstructionCost(Op, DstMVT, CostKind);
+ MVT VTypeMVT = DstLT.second.changeVectorElementType(ElementMVT);
+ Cost += getRISCVInstructionCost(Op, VTypeMVT, CostKind);
+ if (DstEltSize > SrcEltSize)
+ SrcEltSize = SrcEltSize << 1;
+ else
+ DstEltSize = DstEltSize << 1;
----------------
arcbbb wrote:
This doesn't handle lmul8 correctly. I will split it into a separate PR to fix.
https://github.com/llvm/llvm-project/pull/121556
More information about the llvm-commits
mailing list