Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64]Add memory op cost model for SVE
This patch adds/fixes memory op cost model for SVE with fixed-width vector. Differential Revision: https://reviews.llvm.org/D90950
- Loading branch information
1 parent
04ce13e
commit 37f4ccb
Showing
8 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
; Check memory cost model action for fixed vector SVE and Neon | ||
; Vector bits size lower than 256 bits end up assuming Neon cost model | ||
; CHECK-NEON has same performance as CHECK-SVE-128 | ||
|
||
; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+neon < %s | FileCheck %s --check-prefix=CHECK-NEON | ||
; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve -aarch64-sve-vector-bits-min=128 < %s | FileCheck %s --check-prefix=CHECK-SVE-128 | ||
; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-SVE-256 | ||
; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve -aarch64-sve-vector-bits-min=512 < %s | FileCheck %s --check-prefix=CHECK-SVE-512 | ||
|
||
define <16 x i8> @load16(<16 x i8>* %ptr) { | ||
; CHECK: 'Cost Model Analysis' for function 'load16': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
%out = load <16 x i8>, <16 x i8>* %ptr | ||
ret <16 x i8> %out | ||
} | ||
|
||
define void @store16(<16 x i8>* %ptr, <16 x i8> %val) { | ||
; CHECK: 'Cost Model Analysis' for function 'store16': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
store <16 x i8> %val, <16 x i8>* %ptr | ||
ret void | ||
} | ||
|
||
define <8 x i8> @load8(<8 x i8>* %ptr) { | ||
; CHECK: 'Cost Model Analysis' for function 'load8': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
%out = load <8 x i8>, <8 x i8>* %ptr | ||
ret <8 x i8> %out | ||
} | ||
|
||
define void @store8(<8 x i8>* %ptr, <8 x i8> %val) { | ||
; CHECK: 'Cost Model Analysis' for function 'store8': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
store <8 x i8> %val, <8 x i8>* %ptr | ||
ret void | ||
} | ||
|
||
define <4 x i8> @load4(<4 x i8>* %ptr) { | ||
; CHECK: 'Cost Model Analysis' for function 'load4': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 64 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 64 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
%out = load <4 x i8>, <4 x i8>* %ptr | ||
ret <4 x i8> %out | ||
} | ||
|
||
define void @store4(<4 x i8>* %ptr, <4 x i8> %val) { | ||
; CHECK: 'Cost Model Analysis' for function 'store4': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
store <4 x i8> %val, <4 x i8>* %ptr | ||
ret void | ||
} | ||
|
||
define <16 x i16> @load_256(<16 x i16>* %ptr) { | ||
; CHECK: 'Cost Model Analysis' for function 'load_256': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 2 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 2 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
%out = load <16 x i16>, <16 x i16>* %ptr | ||
ret <16 x i16> %out | ||
} | ||
|
||
define <8 x i64> @load_512(<8 x i64>* %ptr) { | ||
; CHECK: 'Cost Model Analysis' for function 'load_512': | ||
; CHECK-NEON: Cost Model: Found an estimated cost of 4 for instruction: | ||
; CHECK-SVE-128: Cost Model: Found an estimated cost of 4 for instruction: | ||
; CHECK-SVE-256: Cost Model: Found an estimated cost of 2 for instruction: | ||
; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction: | ||
%out = load <8 x i64>, <8 x i64>* %ptr | ||
ret <8 x i64> %out | ||
} |
51 changes: 51 additions & 0 deletions
51
llvm/test/Analysis/CostModel/AArch64/scalable-mem-op-cost-model.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; 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 | ||
} |