From be663c4337c6e3d81a9a539abc11477fdb74cc6e Mon Sep 17 00:00:00 2001 From: Sander de Smalen Date: Mon, 7 Jun 2021 16:55:44 +0100 Subject: [PATCH] [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. --- .../AArch64/scalable-mem-op-cost-model.ll | 51 --------------------- llvm/test/Analysis/CostModel/AArch64/sve-gather.ll | 51 ++++++--------------- llvm/test/Analysis/CostModel/AArch64/sve-ldst.ll | 23 ++++++++++ .../test/Analysis/CostModel/AArch64/sve-scatter.ll | 52 ++++++---------------- 4 files changed, 51 insertions(+), 126 deletions(-) delete mode 100644 llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll create mode 100644 llvm/test/Analysis/CostModel/AArch64/sve-ldst.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 1a7b262..0000000 --- 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 @load-sve-8(* %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 , * %ptr - ret %retval -} - -define void @store-sve-8(* %ptr, %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 %val, * %ptr - ret void -} - -define @load-sve-16(* %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 , * %ptr - ret %retval -} - -define void @store-sve-16(* %ptr, %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 %val, * %ptr - ret void -} - -define @load-sve-32(* %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 , * %ptr - ret %retval -} - -define void @store-sve-32(* %ptr, %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 %val, * %ptr - ret void -} diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll b/llvm/test/Analysis/CostModel/AArch64/sve-gather.ll index 6659aff..283bf81 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 @masked_gather_nxv4i32( %ld, %masks, %passthru) { -; CHECK-LABEL: 'masked_gather_nxv4i32' -; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %res = call @llvm.masked.gather.nxv4i32.nxv4p0i32( %ld, i32 0, %masks, %passthru) -; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret %res - %res = call @llvm.masked.gather.nxv4i32( %ld, i32 0, %masks, %passthru) - ret %res +define void @masked_gathers( %nxv4i1mask, %nxv8i1mask, <4 x i1> %v4i1mask, <1 x i1> %v1i1mask, %nxv1i1mask) { +; CHECK-LABEL: 'masked_gathers' +; CHECK-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %res.nxv4i32 = call @llvm.masked.gather.nxv4i32.nxv4p0i32 +; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %res.nxv8i32 = call @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 @llvm.masked.gather.nxv4i32( undef, i32 0, %nxv4i1mask, zeroinitializer) + %res.nxv8i32 = call @llvm.masked.gather.nxv8i32( undef, i32 0, %nxv8i1mask, 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 @masked_gather_nxv8i32( %ld, %masks, %passthru) { -; CHECK-LABEL: 'masked_gather_nxv8i32' -; CHECK-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %res = call @llvm.masked.gather.nxv8i32.nxv8p0i32( %ld, i32 0, %masks, %passthru) -; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret %res - %res = call @llvm.masked.gather.nxv8i32( %ld, i32 0, %masks, %passthru) - ret %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 @llvm.masked.gather.nxv4i32( %ptrs, i32 %align, %masks, %passthru) -declare @llvm.masked.gather.nxv8i32( %ptrs, i32 %align, %masks, %passthru) -declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ptrs, i32 %align, <4 x i1> %masks, <4 x i32> %passthru) +declare @llvm.masked.gather.nxv4i32(, i32, , ) +declare @llvm.masked.gather.nxv8i32(, 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 0000000..6e81671 --- /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 , * undef + %res.nxv16i8 = load , * undef + %res.nxv32i8 = load , * undef + ret void +} + +define void @scalable_stores() { +; CHECK-LABEL: 'scalable_stores' +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store + store undef, * undef + store undef, * undef + store undef, * undef + ret void +} diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll b/llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll index 780449a..872e734 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( %data, %ptrs, %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( %data, %ptrs, i32 0, %masks) -; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void - - call void @llvm.masked.scatter.nxv4i32( %data, %ptrs, i32 0, %masks) - ret void -} - -define void @masked_scatter_nxv8i32( %data, %ptrs, %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( %data, %ptrs, i32 0, %masks) -; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void - - call void @llvm.masked.scatter.nxv8i32( %data, %ptrs, i32 0, %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( %nxv4i1mask, %nxv8i1mask, <4 x i1> %v4i1mask, <1 x i1> %v1i1mask, %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( undef, undef, i32 0, %nxv4i1mask) + call void @llvm.masked.scatter.nxv8i32( undef, undef, i32 0, %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( %data, %ptrs, i32 %align, %masks) -declare void @llvm.masked.scatter.nxv8i32( %data, %ptrs, i32 %align, %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(, , i32, ) +declare void @llvm.masked.scatter.nxv8i32(, , i32, ) +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>) -- 2.7.4