xref: /llvm-project/llvm/test/Transforms/Inline/AArch64/sme-pstatesm-attrs-low-threshold.ll (revision 00a831421fdd94aec65221bdb37042c1aacfe8e0)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -mattr=+sme -S -passes=inline  -inlinedefault-threshold=1 | FileCheck %s
3
4; This test sets the inline-threshold to 1 such that by default the call to @streaming_callee is not inlined.
5; However, if the call to @streaming_callee requires a streaming-mode change, it should always inline the call because the streaming-mode change is more expensive.
6target triple = "aarch64"
7
8declare void @streaming_compatible_f() "aarch64_pstate_sm_compatible"
9
10; Function @streaming_callee doesn't contain any operations that may use ZA
11; state and therefore can be legally inlined into a normal function.
12define void @streaming_callee() "aarch64_pstate_sm_enabled" {
13; CHECK-LABEL: define void @streaming_callee
14; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
15; CHECK-NEXT:    call void @streaming_compatible_f()
16; CHECK-NEXT:    call void @streaming_compatible_f()
17; CHECK-NEXT:    ret void
18;
19  call void @streaming_compatible_f()
20  call void @streaming_compatible_f()
21  ret void
22}
23
24; Inline call to @streaming_callee to remove a streaming mode change.
25define void @non_streaming_caller_inline() {
26; CHECK-LABEL: define void @non_streaming_caller_inline
27; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
28; CHECK-NEXT:    call void @streaming_compatible_f()
29; CHECK-NEXT:    call void @streaming_compatible_f()
30; CHECK-NEXT:    ret void
31;
32  call void @streaming_callee()
33  ret void
34}
35
36; Don't inline call to @streaming_callee when the inline-threshold is set to 1, because it does not eliminate a streaming-mode change.
37define void @streaming_caller_dont_inline() "aarch64_pstate_sm_enabled" {
38; CHECK-LABEL: define void @streaming_caller_dont_inline
39; CHECK-SAME: () #[[ATTR1]] {
40; CHECK-NEXT:    call void @streaming_callee()
41; CHECK-NEXT:    ret void
42;
43  call void @streaming_callee()
44  ret void
45}
46