[llvm] d94ed83 - [AArch64] Fix assertion failure in getCastInstrCost
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 03:48:34 PDT 2024
Author: Sander de Smalen
Date: 2024-07-16T10:43:07Z
New Revision: d94ed83a9e7c0f20623899ad19f90d383760cb68
URL: https://github.com/llvm/llvm-project/commit/d94ed83a9e7c0f20623899ad19f90d383760cb68
DIFF: https://github.com/llvm/llvm-project/commit/d94ed83a9e7c0f20623899ad19f90d383760cb68.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/AArch64/no-sve-no-neon.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 0ee8136884119..45148449dfb82 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -2785,7 +2785,7 @@ InstructionCost AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
std::pair<InstructionCost, MVT> LT =
getTypeLegalizationCost(WiderTy.getTypeForEVT(Dst->getContext()));
unsigned NumElements = AArch64::SVEBitsPerBlock /
- LT.second.getVectorElementType().getSizeInBits();
+ LT.second.getScalarSizeInBits();
return AdjustCost(
LT.first *
getCastInstrCost(
diff --git a/llvm/test/Analysis/CostModel/AArch64/no-sve-no-neon.ll b/llvm/test/Analysis/CostModel/AArch64/no-sve-no-neon.ll
index df1e542049ea0..4e6a36059d815 100644
--- a/llvm/test/Analysis/CostModel/AArch64/no-sve-no-neon.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/no-sve-no-neon.ll
@@ -1,10 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
-; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
+; RUN: opt -mattr=-neon < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
+; RUN: opt -mattr=+sve,-neon < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
target triple = "aarch64-unknown-linux-gnu"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
-define void @uitofp() #0 {
+define void @uitofp() {
; CHECK-LABEL: 'uitofp'
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %conv = uitofp <16 x i64> undef to <16 x float>
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
@@ -12,5 +13,3 @@ define void @uitofp() #0 {
%conv = uitofp <16 x i64> undef to <16 x float>
ret void
}
-
-attributes #0 = { "target-features"="-neon" }
More information about the llvm-commits
mailing list