@@ -2296,7 +2296,10 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
22962296 { ISD::FP_EXTEND, MVT::v8f64, MVT::v8f32, { 1 , 1 , 1 , 1 } },
22972297 { ISD::FP_EXTEND, MVT::v8f64, MVT::v16f32, { 3 , 1 , 1 , 1 } },
22982298 { ISD::FP_EXTEND, MVT::v16f64, MVT::v16f32, { 4 , 1 , 1 , 1 } }, // 2*vcvtps2pd+vextractf64x4
2299+ { ISD::FP_EXTEND, MVT::v16f32, MVT::v16f16, { 1 , 1 , 1 , 1 } }, // vcvtph2ps
2300+ { ISD::FP_EXTEND, MVT::v8f64, MVT::v8f16, { 2 , 1 , 1 , 1 } }, // vcvtph2ps+vcvtps2pd
22992301 { ISD::FP_ROUND, MVT::v8f32, MVT::v8f64, { 1 , 1 , 1 , 1 } },
2302+ { ISD::FP_ROUND, MVT::v16f16, MVT::v16f32, { 1 , 1 , 1 , 1 } }, // vcvtps2ph
23002303
23012304 { ISD::TRUNCATE, MVT::v2i1, MVT::v2i8, { 3 , 1 , 1 , 1 } }, // sext+vpslld+vptestmd
23022305 { ISD::TRUNCATE, MVT::v4i1, MVT::v4i8, { 3 , 1 , 1 , 1 } }, // sext+vpslld+vptestmd
@@ -2973,6 +2976,14 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
29732976 { ISD::TRUNCATE, MVT::v4i32, MVT::v2i64, { 1 , 1 , 1 , 1 } }, // PSHUFD
29742977 };
29752978
2979+ static const TypeConversionCostKindTblEntry F16ConversionTbl[] = {
2980+ { ISD::FP_ROUND, MVT::v8f16, MVT::v8f32, { 1 , 1 , 1 , 1 } }, // vcvtps2ph
2981+ { ISD::FP_ROUND, MVT::v4f16, MVT::v4f32, { 1 , 1 , 1 , 1 } }, // vcvtps2ph
2982+ { ISD::FP_EXTEND, MVT::v8f32, MVT::v8f16, { 1 , 1 , 1 , 1 } }, // vcvtph2ps
2983+ { ISD::FP_EXTEND, MVT::v4f32, MVT::v4f16, { 1 , 1 , 1 , 1 } }, // vcvtph2ps
2984+ { ISD::FP_EXTEND, MVT::v4f64, MVT::v4f16, { 2 , 1 , 1 , 1 } }, // vcvtph2ps+vcvtps2pd
2985+ };
2986+
29762987 // Attempt to map directly to (simple) MVT types to let us match custom entries.
29772988 EVT SrcTy = TLI->getValueType (DL, Src);
29782989 EVT DstTy = TLI->getValueType (DL, Dst);
@@ -3034,6 +3045,13 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
30343045 return *KindCost;
30353046 }
30363047
3048+ if (ST->hasF16C ()) {
3049+ if (const auto *Entry = ConvertCostTableLookup (F16ConversionTbl, ISD,
3050+ SimpleDstTy, SimpleSrcTy))
3051+ if (auto KindCost = Entry->Cost [CostKind])
3052+ return *KindCost;
3053+ }
3054+
30373055 if (ST->hasSSE41 ()) {
30383056 if (const auto *Entry = ConvertCostTableLookup (SSE41ConversionTbl, ISD,
30393057 SimpleDstTy, SimpleSrcTy))
@@ -3107,6 +3125,13 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
31073125 if (auto KindCost = Entry->Cost [CostKind])
31083126 return std::max (LTSrc.first , LTDest.first ) * *KindCost;
31093127
3128+ if (ST->hasF16C ()) {
3129+ if (const auto *Entry = ConvertCostTableLookup (F16ConversionTbl, ISD,
3130+ LTDest.second , LTSrc.second ))
3131+ if (auto KindCost = Entry->Cost [CostKind])
3132+ return std::max (LTSrc.first , LTDest.first ) * *KindCost;
3133+ }
3134+
31103135 if (ST->hasSSE41 ())
31113136 if (const auto *Entry = ConvertCostTableLookup (SSE41ConversionTbl, ISD,
31123137 LTDest.second , LTSrc.second ))
0 commit comments