Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h =================================================================== --- llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -868,6 +868,11 @@ bool shouldExpandGetActiveLaneMask(EVT VT, EVT OpVT) const override; + // Normally SVE is only used for byte size vectors that do not fit within a + // NEON vector. This changes when OverrideNEON is true, allowing SVE to be + // used for 64bit and 128bit vectors as well. + bool useSVEForFixedLengthVectorVT(EVT VT, bool OverrideNEON = false) const; + private: /// Keep a pointer to the AArch64Subtarget around so that we can /// make the right decision when generating code for different targets. @@ -1141,11 +1146,6 @@ bool isTargetCanonicalConstantNode(SDValue Op) const override; - // Normally SVE is only used for byte size vectors that do not fit within a - // NEON vector. This changes when OverrideNEON is true, allowing SVE to be - // used for 64bit and 128bit vectors as well. - bool useSVEForFixedLengthVectorVT(EVT VT, bool OverrideNEON = false) const; - // With the exception of data-predicate transitions, no instructions are // required to cast between legal scalable vector types. However: // 1. Packed and unpacked types have different bit lengths, meaning BITCAST Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -1893,6 +1893,20 @@ FP16Tbl, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT())) return AdjustCost(Entry->Cost); + static const TypeConversionCostTblEntry SVEFixed[] = { + // Truncate from v4f64 to v4f32. + {ISD::FP_ROUND, MVT::v4f32, MVT::v4f64, 3}, + // Extend from v4f32 to v4f64. + {ISD::FP_EXTEND, MVT::v4f64, MVT::v4f32, 2}, + }; + + if (ST->hasSVE() && + (getTLI()->useSVEForFixedLengthVectorVT(SrcTy.getSimpleVT()) || + getTLI()->useSVEForFixedLengthVectorVT(DstTy.getSimpleVT()))) + if (const auto *Entry = ConvertCostTableLookup( + SVEFixed, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT())) + return AdjustCost(Entry->Cost); + return AdjustCost( BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I)); }