Skip to content

Commit d94ed83

Browse files
committed
[AArch64] Fix assertion failure in getCastInstrCost
We should not call `getVectorElementType` on the result MVT from `getTypeLegalizationCost` when we don't if the legal type is a vector. This is the case when the type needs to be legalized using scalarization.
1 parent 977cb5d commit d94ed83

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,7 @@ InstructionCost AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
27852785
std::pair<InstructionCost, MVT> LT =
27862786
getTypeLegalizationCost(WiderTy.getTypeForEVT(Dst->getContext()));
27872787
unsigned NumElements = AArch64::SVEBitsPerBlock /
2788-
LT.second.getVectorElementType().getSizeInBits();
2788+
LT.second.getScalarSizeInBits();
27892789
return AdjustCost(
27902790
LT.first *
27912791
getCastInstrCost(
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2-
; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
2+
; RUN: opt -mattr=-neon < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
3+
; RUN: opt -mattr=+sve,-neon < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
34

45
target triple = "aarch64-unknown-linux-gnu"
56
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
67

7-
define void @uitofp() #0 {
8+
define void @uitofp() {
89
; CHECK-LABEL: 'uitofp'
910
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %conv = uitofp <16 x i64> undef to <16 x float>
1011
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1112
;
1213
%conv = uitofp <16 x i64> undef to <16 x float>
1314
ret void
1415
}
15-
16-
attributes #0 = { "target-features"="-neon" }

0 commit comments

Comments
 (0)