Index: llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp =================================================================== --- llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp +++ llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -343,6 +343,28 @@ return Entry->Cost; } + static const TypeConversionCostTblEntry MVEVectorConversionTbl[] = { + { ISD::SIGN_EXTEND, MVT::v8i16, MVT::v8i8, 1 }, + { ISD::ZERO_EXTEND, MVT::v8i16, MVT::v8i8, 1 }, + { ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i8, 2 }, + { ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i8, 2 }, + { ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i8, 10 }, + { ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i8, 2 }, + { ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i16, 1 }, + { ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i16, 1 }, + { ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i16, 10 }, + { ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i16, 2 }, + { ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i32, 8 }, + { ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i32, 2 }, + }; + + if (SrcTy.isVector() && ST->hasMVEIntegerOps()) { + if (const auto *Entry = ConvertCostTableLookup(MVEVectorConversionTbl, + ISD, DstTy.getSimpleVT(), + SrcTy.getSimpleVT())) + return Entry->Cost * ST->getMVEVectorCostFactor(); + } + // Scalar integer conversion costs. static const TypeConversionCostTblEntry ARMIntegerConversionTbl[] = { // i16 -> i64 requires two dependent operations. Index: llvm/test/Analysis/CostModel/ARM/cast.ll =================================================================== --- llvm/test/Analysis/CostModel/ARM/cast.ll +++ llvm/test/Analysis/CostModel/ARM/cast.ll @@ -329,16 +329,16 @@ ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r67 = uitofp i64 undef to float ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %r68 = sitofp i64 undef to double ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %r69 = uitofp i64 undef to double -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %r70 = sext <8 x i8> undef to <8 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 42 for instruction: %r71 = sext <16 x i8> undef to <16 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %r72 = zext <8 x i8> undef to <8 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 42 for instruction: %r73 = zext <16 x i8> undef to <16 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %rext_0 = sext <8 x i8> undef to <8 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 42 for instruction: %rext_1 = zext <8 x i8> undef to <8 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %rext_2 = sext <8 x i16> undef to <8 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 42 for instruction: %rext_3 = zext <8 x i16> undef to <8 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %rext_4 = sext <4 x i16> undef to <4 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %rext_5 = zext <4 x i16> undef to <4 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %r70 = sext <8 x i8> undef to <8 x i32> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %r71 = sext <16 x i8> undef to <16 x i32> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %r72 = zext <8 x i8> undef to <8 x i32> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %r73 = zext <16 x i8> undef to <16 x i32> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 330 for instruction: %rext_0 = sext <8 x i8> undef to <8 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %rext_1 = zext <8 x i8> undef to <8 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 330 for instruction: %rext_2 = sext <8 x i16> undef to <8 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 74 for instruction: %rext_3 = zext <8 x i16> undef to <8 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 82 for instruction: %rext_4 = sext <4 x i16> undef to <4 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %rext_5 = zext <4 x i16> undef to <4 x i64> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r74 = trunc <8 x i32> undef to <8 x i8> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %r75 = trunc <16 x i32> undef to <16 x i8> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r80 = fptrunc double undef to float @@ -866,14 +866,14 @@ ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %v1 = zext <8 x i8> %loadv8i8 to <8 x i16> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %v2 = sext <4 x i8> %loadv4i8 to <4 x i32> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %v3 = zext <4 x i8> %loadv4i8 to <4 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4 = sext <2 x i8> %loadv2i8 to <2 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v5 = zext <2 x i8> %loadv2i8 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %v4 = sext <2 x i8> %loadv2i8 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5 = zext <2 x i8> %loadv2i8 to <2 x i64> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %v6 = sext <4 x i16> %loadv4i16 to <4 x i32> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %v7 = zext <4 x i16> %loadv4i16 to <4 x i32> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v8 = sext <2 x i16> %loadv2i16 to <2 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v9 = zext <2 x i16> %loadv2i16 to <2 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v10 = sext <2 x i32> %loadv2i32 to <2 x i64> -; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v11 = zext <2 x i32> %loadv2i32 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %v8 = sext <2 x i16> %loadv2i16 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v9 = zext <2 x i16> %loadv2i16 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %v10 = sext <2 x i32> %loadv2i32 to <2 x i64> +; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v11 = zext <2 x i32> %loadv2i32 to <2 x i64> ; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef ;