diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp --- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -2059,6 +2059,15 @@ { ISD::BITCAST, MVT::nxv2i16, MVT::nxv2f16, 0 }, { ISD::BITCAST, MVT::nxv4i16, MVT::nxv4f16, 0 }, { ISD::BITCAST, MVT::nxv2i32, MVT::nxv2f32, 0 }, + + // Add high cost for extending to illegal -too wide- scalable vectors. + { ISD::ZERO_EXTEND, MVT::nxv16i16, MVT::nxv16i8, 16}, + { ISD::ZERO_EXTEND, MVT::nxv16i32, MVT::nxv16i8, 32}, + { ISD::ZERO_EXTEND, MVT::nxv16i64, MVT::nxv16i8, 64}, + + { ISD::SIGN_EXTEND, MVT::nxv16i16, MVT::nxv16i8, 16}, + { ISD::SIGN_EXTEND, MVT::nxv16i32, MVT::nxv16i8, 32}, + { ISD::SIGN_EXTEND, MVT::nxv16i64, MVT::nxv16i8, 64}, }; if (const auto *Entry = ConvertCostTableLookup(ConversionTbl, ISD, diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-ext.ll b/llvm/test/Analysis/CostModel/AArch64/sve-ext.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Analysis/CostModel/AArch64/sve-ext.ll @@ -0,0 +1,25 @@ +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py +; RUN: opt -passes="print" 2>&1 -disable-output -mtriple aarch64-linux-gnu -mattr=+sve -S -o - < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +define void @sve_ext() { +; CHECK-LABEL: 'sve_ext' +; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %zext_nxv16_i8_to_i16 = zext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %zext_nxv16_i8_to_i32 = zext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %zext_nxv16_i8_to_i64 = zext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %sext_nxv16_i8_to_i16 = sext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %sext_nxv16_i8_to_i32 = sext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %sext_nxv16_i8_to_i64 = sext undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void +; + %zext_nxv16_i8_to_i16 = zext undef to + %zext_nxv16_i8_to_i32 = zext undef to + %zext_nxv16_i8_to_i64 = zext undef to + + %sext_nxv16_i8_to_i16 = sext undef to + %sext_nxv16_i8_to_i32 = sext undef to + %sext_nxv16_i8_to_i64 = sext undef to + + ret void +}