[llvm] c06b7e2 - [SVE] Fix implicit TypeSize->uint64_t conversion getCastInstrCost
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 00:16:47 PDT 2020
Author: David Sherwood
Date: 2020-07-14T08:16:31+01:00
New Revision: c06b7e2ab5167ad031745a706204abed1aefd823
URL: https://github.com/llvm/llvm-project/commit/c06b7e2ab5167ad031745a706204abed1aefd823
DIFF: https://github.com/llvm/llvm-project/commit/c06b7e2ab5167ad031745a706204abed1aefd823.diff
LOG: [SVE] Fix implicit TypeSize->uint64_t conversion getCastInstrCost
In getCastInstrCost() when comparing different sizes for src and
dst types we should be using the TypeSize comparison operators
instead of relying upon TypeSize being converted a uin64_t.
Previously this meant we were dropping the scalable property and
treating fixed and scalable vector types the same.
Differential Revision: https://reviews.llvm.org/D83461
Added:
llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll
Modified:
llvm/include/llvm/CodeGen/BasicTTIImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index f9d32eadd23e..407f09063dce 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -702,8 +702,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(DL, Src);
std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(DL, Dst);
- unsigned SrcSize = SrcLT.second.getSizeInBits();
- unsigned DstSize = DstLT.second.getSizeInBits();
+ TypeSize SrcSize = SrcLT.second.getSizeInBits();
+ TypeSize DstSize = DstLT.second.getSizeInBits();
bool IntOrPtrSrc = Src->isIntegerTy() || Src->isPointerTy();
bool IntOrPtrDst = Dst->isIntegerTy() || Dst->isPointerTy();
@@ -777,8 +777,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
// Check vector-to-vector casts.
if (DstVTy && SrcVTy) {
// If the cast is between same-sized registers, then the check is simple.
- if (SrcLT.first == DstLT.first &&
- SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {
+ if (SrcLT.first == DstLT.first && SrcSize == DstSize) {
// Assume that Zext is done using AND.
if (Opcode == Instruction::ZExt)
diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll b/llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll
new file mode 100644
index 000000000000..c9695061e7f1
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll
@@ -0,0 +1,12 @@
+; RUN: opt -mtriple=aarch64-linux-gnu -mattr=+sve -cost-model -analyze < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
+; WARN-NOT: warning
+
+; CHECK: Found an estimated cost of 0 for instruction: %b = bitcast <vscale x 2 x double> %a to <vscale x 2 x i64>
+
+define <vscale x 2 x i64> @foo(<vscale x 2 x double> %a, i32 %x) {
+ %b = bitcast <vscale x 2 x double> %a to <vscale x 2 x i64>
+ ret <vscale x 2 x i64> %b
+}
More information about the llvm-commits
mailing list