[llvm] be663c4 - [CostModel][AArch64] NFC: Simplify some cost model tests for SVE.

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 09:26:50 PDT 2021


Author: Sander de Smalen
Date: 2021-06-07T17:26:23+01:00
New Revision: be663c4337c6e3d81a9a539abc11477fdb74cc6e

URL: https://github.com/llvm/llvm-project/commit/be663c4337c6e3d81a9a539abc11477fdb74cc6e
DIFF: https://github.com/llvm/llvm-project/commit/be663c4337c6e3d81a9a539abc11477fdb74cc6e.diff

LOG: [CostModel][AArch64] NFC: Simplify some cost model tests for SVE.

* Merged some functions into a single function, to make the costs more obvious.
* Moved scalable-mem-op-cost-model.ll -> sve-ldst.ll to be more consistent with other filenames.

Added: 
    llvm/test/Analysis/CostModel/AArch64/sve-ldst.ll

Modified: 
    llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
    llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll

Removed: 
    llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll


################################################################################
diff  --git a/llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll b/llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll
deleted file mode 100644
index 1a7b262ae627..000000000000
--- a/llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; Checks if the memory cost model does not break when using scalable vectors
-
-; RUN: opt  -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
-
-define <vscale x 8 x i8> @load-sve-8(<vscale x 8 x i8>* %ptr) {
-; CHECK-LABEL: 'load-sve-8':
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  %retval = load <vscale x 8 x i8>, <vscale x 8 x i8>* %ptr
-  ret <vscale x 8 x i8> %retval
-}
-
-define void  @store-sve-8(<vscale x 8 x i8>* %ptr, <vscale x 8 x i8> %val) {
-; CHECK-LABEL: 'store-sve-8'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  store <vscale x 8 x i8> %val, <vscale x 8 x i8>* %ptr
-  ret void
-}
-
-define <vscale x 16 x i8> @load-sve-16(<vscale x 16 x i8>* %ptr) {
-; CHECK-LABEL: 'load-sve-16':
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  %retval = load <vscale x 16 x i8>, <vscale x 16 x i8>* %ptr
-  ret <vscale x 16 x i8> %retval
-}
-
-define void  @store-sve-16(<vscale x 16 x i8>* %ptr, <vscale x 16 x i8> %val) {
-; CHECK-LABEL: 'store-sve-16'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  store <vscale x 16 x i8> %val, <vscale x 16 x i8>* %ptr
-  ret void
-}
-
-define <vscale x 32 x i8> @load-sve-32(<vscale x 32 x i8>* %ptr) {
-; CHECK-LABEL: 'load-sve-32':
-; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  %retval = load <vscale x 32 x i8>, <vscale x 32 x i8>* %ptr
-  ret <vscale x 32 x i8> %retval
-}
-
-define void  @store-sve-32(<vscale x 32 x i8>* %ptr, <vscale x 32 x i8> %val) {
-; CHECK-LABEL: 'store-sve-32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:
-  store <vscale x 32 x i8> %val, <vscale x 32 x i8>* %ptr
-  ret void
-}

diff  --git a/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll b/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
index 6659aff08999..283bf811b842 100644
--- a/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
@@ -2,43 +2,20 @@
 
 ; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve  < %s | FileCheck %s
 
-define <vscale x 4 x i32> @masked_gather_nxv4i32(<vscale x 4 x i32*> %ld, <vscale x 4 x i1> %masks, <vscale x 4 x i32> %passthru) {
-; CHECK-LABEL: 'masked_gather_nxv4i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction:   %res = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0i32(<vscale x 4 x i32*> %ld, i32 0, <vscale x 4 x i1> %masks, <vscale x 4 x i32> %passthru)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 4 x i32> %res
-  %res = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x i32*> %ld, i32 0, <vscale x 4 x i1> %masks, <vscale x 4 x i32> %passthru)
-  ret <vscale x 4 x i32> %res
+define void @masked_gathers(<vscale x 4 x i1> %nxv4i1mask, <vscale x 8 x i1> %nxv8i1mask, <4 x i1> %v4i1mask, <1 x i1> %v1i1mask, <vscale x 1 x i1> %nxv1i1mask) {
+; CHECK-LABEL: 'masked_gathers'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction:   %res.nxv4i32 = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction:   %res.nxv8i32 = call <vscale x 8 x i32> @llvm.masked.gather.nxv8i32.nxv8p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 29 for instruction:   %res.v4i32 = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction:   %res.v1i128 = call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128
+  %res.nxv4i32 = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x i32*> undef, i32 0, <vscale x 4 x i1> %nxv4i1mask, <vscale x 4 x i32> zeroinitializer)
+  %res.nxv8i32 = call <vscale x 8 x i32> @llvm.masked.gather.nxv8i32(<vscale x 8 x i32*> undef, i32 0, <vscale x 8 x i1> %nxv8i1mask, <vscale x 8 x i32> zeroinitializer)
+  %res.v4i32 = call <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> undef, i32 0, <4 x i1> %v4i1mask, <4 x i32> zeroinitializer)
+  %res.v1i128 = call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*> undef, i32 0, <1 x i1> %v1i1mask, <1 x i128> zeroinitializer)
+  ret void
 }
 
-define <vscale x 8 x i32> @masked_gather_nxv8i32(<vscale x 8 x i32*> %ld, <vscale x 8 x i1> %masks, <vscale x 8 x i32> %passthru) {
-; CHECK-LABEL: 'masked_gather_nxv8i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction:   %res = call <vscale x 8 x i32> @llvm.masked.gather.nxv8i32.nxv8p0i32(<vscale x 8 x i32*> %ld, i32 0, <vscale x 8 x i1> %masks, <vscale x 8 x i32> %passthru)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 8 x i32> %res
-  %res = call <vscale x 8 x i32> @llvm.masked.gather.nxv8i32(<vscale x 8 x i32*> %ld, i32 0, <vscale x 8 x i1> %masks, <vscale x 8 x i32> %passthru)
-  ret <vscale x 8 x i32> %res
-}
-
-define <4 x i32> @masked_gather_v4i32(<4 x i32*> %ld, <4 x i1> %masks, <4 x i32> %passthru) {
-; CHECK-LABEL: 'masked_gather_v4i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 29 for instruction:   %res = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*> %ld, i32 0, <4 x i1> %masks, <4 x i32> %passthru)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
-
-  %res = call <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ld, i32 0, <4 x i1> %masks, <4 x i32> %passthru)
-  ret <4 x i32> %res
-}
-
-; Check it properly falls back to BasicTTIImpl when legalized MVT is not a vector
-define <1 x i128> @masked_gather_v1i128(<1 x i128*> %ld, <1 x i1> %masks, <1 x i128> %passthru) {
-; CHECK-LABEL: 'masked_gather_v1i128'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction:   %res = call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*> %ld, i32 0, <1 x i1> %masks, <1 x i128> %passthru)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret <1 x i128> %res
-
-  %res = call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*> %ld, i32 0, <1 x i1> %masks, <1 x i128> %passthru)
-  ret <1 x i128> %res
-}
-
-declare <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x i32*> %ptrs, i32 %align, <vscale x 4 x i1> %masks, <vscale x 4 x i32> %passthru)
-declare <vscale x 8 x i32> @llvm.masked.gather.nxv8i32(<vscale x 8 x i32*> %ptrs, i32 %align, <vscale x 8 x i1> %masks, <vscale x 8 x i32> %passthru)
-declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ptrs, i32 %align, <4 x i1> %masks, <4 x i32> %passthru)
+declare <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x i32*>, i32, <vscale x 4 x i1>, <vscale x 4 x i32>)
+declare <vscale x 8 x i32> @llvm.masked.gather.nxv8i32(<vscale x 8 x i32*>, i32, <vscale x 8 x i1>, <vscale x 8 x i32>)
+declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*>, i32, <4 x i1>, <4 x i32>)
 declare <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*>, i32, <1 x i1>, <1 x i128>)
-

diff  --git a/llvm/test/Analysis/CostModel/AArch64/sve-ldst.ll b/llvm/test/Analysis/CostModel/AArch64/sve-ldst.ll
new file mode 100644
index 000000000000..6e8167130c4e
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-ldst.ll
@@ -0,0 +1,23 @@
+; RUN: opt  -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define void @scalable_loads() {
+; CHECK-LABEL: 'scalable_loads'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %res.nxv8i8
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %res.nxv16i8
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res.nxv32i8
+  %res.nxv8i8 = load <vscale x 8 x i8>, <vscale x 8 x i8>* undef
+  %res.nxv16i8 = load <vscale x 16 x i8>, <vscale x 16 x i8>* undef
+  %res.nxv32i8 = load <vscale x 32 x i8>, <vscale x 32 x i8>* undef
+  ret void
+}
+
+define void @scalable_stores() {
+; CHECK-LABEL: 'scalable_stores'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 8 x i8>
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 16 x i8>
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store <vscale x 32 x i8>
+  store <vscale x 8 x i8> undef, <vscale x 8 x i8>* undef
+  store <vscale x 16 x i8> undef, <vscale x 16 x i8>* undef
+  store <vscale x 32 x i8> undef, <vscale x 32 x i8>* undef
+  ret void
+}

diff  --git a/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll b/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll
index 780449a50696..872e73427e8b 100644
--- a/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll
@@ -2,44 +2,20 @@
 
 ; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve  < %s | FileCheck %s
 
-define void @masked_scatter_nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32*> %ptrs, <vscale x 4 x i1> %masks) {
-; CHECK-LABEL: 'masked_scatter_nxv4i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction:   call void @llvm.masked.scatter.nxv4i32.nxv4p0i32(<vscale x 4 x i32> %data, <vscale x 4 x i32*> %ptrs, i32 0, <vscale x 4 x i1> %masks)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret void
-
-  call void @llvm.masked.scatter.nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32*> %ptrs, i32 0, <vscale x 4 x i1> %masks)
-  ret void
-}
-
-define void @masked_scatter_nxv8i32(<vscale x 8 x i32> %data, <vscale x 8 x i32*> %ptrs, <vscale x 8 x i1> %masks) {
-; CHECK-LABEL: 'masked_scatter_nxv8i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction:   call void @llvm.masked.scatter.nxv8i32.nxv8p0i32(<vscale x 8 x i32> %data, <vscale x 8 x i32*> %ptrs, i32 0, <vscale x 8 x i1> %masks)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret void
-
-  call void @llvm.masked.scatter.nxv8i32(<vscale x 8 x i32> %data, <vscale x 8 x i32*> %ptrs, i32 0, <vscale x 8 x i1> %masks)
-  ret void
-}
-
-define void @masked_scatter_v4i32(<4 x i32> %data, <4 x i32*> %ptrs, <4 x i1> %masks) {
-; CHECK-LABEL: 'masked_scatter_v4i32'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 29 for instruction:   call void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i32> %data, <4 x i32*> %ptrs, i32 0, <4 x i1> %masks)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret void
-
-  call void @llvm.masked.scatter.v4i32(<4 x i32> %data, <4 x i32*> %ptrs, i32 0, <4 x i1> %masks)
-  ret void
-}
-
-; Check it properly falls back to BasicTTIImpl when legalized MVT is not a vector
-define void @masked_scatter_v1i128(<1 x i128> %data, <1 x i128*> %ptrs, <1 x i1> %masks) {
-; CHECK-LABEL: 'masked_scatter_v1i128'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction:   call void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> %data, <1 x i128*> %ptrs, i32 0, <1 x i1> %masks)
-; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret void
-
-  call void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> %data, <1 x i128*> %ptrs, i32 0, <1 x i1> %masks)
+define void @masked_scatters(<vscale x 4 x i1> %nxv4i1mask, <vscale x 8 x i1> %nxv8i1mask, <4 x i1> %v4i1mask, <1 x i1> %v1i1mask, <vscale x 1 x i1> %nxv1i1mask) {
+; CHECK-LABEL: 'masked_scatters'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction: call void @llvm.masked.scatter.nxv4i32.nxv4p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction: call void @llvm.masked.scatter.nxv8i32.nxv8p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 29 for instruction: call void @llvm.masked.scatter.v4i32.v4p0i32
+; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: call void @llvm.masked.scatter.v1i128.v1p0i128
+  call void @llvm.masked.scatter.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i32*> undef, i32 0, <vscale x 4 x i1> %nxv4i1mask)
+  call void @llvm.masked.scatter.nxv8i32(<vscale x 8 x i32> undef, <vscale x 8 x i32*> undef, i32 0, <vscale x 8 x i1> %nxv8i1mask)
+  call void @llvm.masked.scatter.v4i32(<4 x i32> undef, <4 x i32*> undef, i32 0, <4 x i1> %v4i1mask)
+  call void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> undef, <1 x i128*> undef, i32 0, <1 x i1> %v1i1mask)
   ret void
 }
 
-declare void @llvm.masked.scatter.nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32*> %ptrs, i32 %align, <vscale x 4 x i1> %masks)
-declare void @llvm.masked.scatter.nxv8i32(<vscale x 8 x i32> %data, <vscale x 8 x i32*> %ptrs, i32 %align, <vscale x 8 x i1> %masks)
-declare void @llvm.masked.scatter.v4i32(<4 x i32> %data, <4 x i32*> %ptrs, i32 %align, <4 x i1> %masks)
-declare void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> %data, <1 x i128*> %ptrs, i32 %align, <1 x i1> %masks)
+declare void @llvm.masked.scatter.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32*>, i32, <vscale x 4 x i1>)
+declare void @llvm.masked.scatter.nxv8i32(<vscale x 8 x i32>, <vscale x 8 x i32*>, i32, <vscale x 8 x i1>)
+declare void @llvm.masked.scatter.v4i32(<4 x i32>, <4 x i32*>, i32, <4 x i1>)
+declare void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128>, <1 x i128*>, i32, <1 x i1>)


        


More information about the llvm-commits mailing list