diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -1004,6 +1004,10 @@ CostKind, I)); } + // Scalarization cost is Invalid, can't assume any num elements. + if (isa(DstVTy)) + return InstructionCost::getInvalid(); + // In other cases where the source or destination are illegal, assume // the operation will get scalarized. unsigned Num = cast(DstVTy)->getNumElements(); diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-fptoi.ll b/llvm/test/Analysis/CostModel/AArch64/sve-fptoi.ll --- a/llvm/test/Analysis/CostModel/AArch64/sve-fptoi.ll +++ b/llvm/test/Analysis/CostModel/AArch64/sve-fptoi.ll @@ -5,6 +5,24 @@ define void @sve-fptoi() { ; CHECK-LABEL: 'sve-fptoi' +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_si8 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_ui8 = fptoui undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_si32 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_ui32 = fptoui undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_si64 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f16_to_ui64 = fptoui undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_si8 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_ui8 = fptoui undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_si16 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_ui16 = fptoui undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_si64 = fptosi undef to +; CHECK-NEXT: Cost Model: Invalid cost for instruction: %nv1f32_to_ui64 = fptoui undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_si8 = fptosi undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_ui8 = fptoui undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_si16 = fptosi undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_ui16 = fptoui undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_si32 = fptosi undef to +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv1f64_to_ui32 = fptoui undef to ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv2f16_to_si8 = fptosi undef to ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv2f16_to_ui8 = fptoui undef to ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nv2f16_to_si32 = fptosi undef to @@ -59,6 +77,26 @@ ; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %nv8f64_to_ui16 = fptoui undef to ; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %nv8f64_to_si32 = fptosi undef to ; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %nv8f64_to_ui32 = fptoui undef to + %nv1f16_to_si8 = fptosi undef to + %nv1f16_to_ui8 = fptoui undef to + %nv1f16_to_si32 = fptosi undef to + %nv1f16_to_ui32 = fptoui undef to + %nv1f16_to_si64 = fptosi undef to + %nv1f16_to_ui64 = fptoui undef to + + %nv1f32_to_si8 = fptosi undef to + %nv1f32_to_ui8 = fptoui undef to + %nv1f32_to_si16 = fptosi undef to + %nv1f32_to_ui16 = fptoui undef to + %nv1f32_to_si64 = fptosi undef to + %nv1f32_to_ui64 = fptoui undef to + + %nv1f64_to_si8 = fptosi undef to + %nv1f64_to_ui8 = fptoui undef to + %nv1f64_to_si16 = fptosi undef to + %nv1f64_to_ui16 = fptoui undef to + %nv1f64_to_si32 = fptosi undef to + %nv1f64_to_ui32 = fptoui undef to %nv2f16_to_si8 = fptosi undef to %nv2f16_to_ui8 = fptoui undef to