1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64 -mattr=+sme < %s | FileCheck %s
4 declare void @private_za_callee()
5 declare float @llvm.cos.f32(float)
7 ; Test lazy-save mechanism for a single callee.
8 define void @test_lazy_save_1_callee() nounwind "aarch64_pstate_za_shared" {
9 ; CHECK-LABEL: test_lazy_save_1_callee:
11 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
12 ; CHECK-NEXT: mov x29, sp
13 ; CHECK-NEXT: sub sp, sp, #16
14 ; CHECK-NEXT: rdsvl x8, #1
15 ; CHECK-NEXT: mov x9, sp
16 ; CHECK-NEXT: mul x8, x8, x8
17 ; CHECK-NEXT: sub x9, x9, x8
18 ; CHECK-NEXT: mov sp, x9
19 ; CHECK-NEXT: stur x9, [x29, #-16]
20 ; CHECK-NEXT: sub x9, x29, #16
21 ; CHECK-NEXT: sturh w8, [x29, #-8]
22 ; CHECK-NEXT: msr TPIDR2_EL0, x9
23 ; CHECK-NEXT: bl private_za_callee
24 ; CHECK-NEXT: smstart za
25 ; CHECK-NEXT: mrs x8, TPIDR2_EL0
26 ; CHECK-NEXT: sub x0, x29, #16
27 ; CHECK-NEXT: cbnz x8, .LBB0_2
28 ; CHECK-NEXT: // %bb.1:
29 ; CHECK-NEXT: bl __arm_tpidr2_restore
30 ; CHECK-NEXT: .LBB0_2:
31 ; CHECK-NEXT: msr TPIDR2_EL0, xzr
32 ; CHECK-NEXT: mov sp, x29
33 ; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
35 call void @private_za_callee()
39 ; Test lazy-save mechanism for multiple callees.
40 define void @test_lazy_save_2_callees() nounwind "aarch64_pstate_za_shared" {
41 ; CHECK-LABEL: test_lazy_save_2_callees:
43 ; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill
44 ; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
45 ; CHECK-NEXT: mov x29, sp
46 ; CHECK-NEXT: sub sp, sp, #16
47 ; CHECK-NEXT: rdsvl x8, #1
48 ; CHECK-NEXT: mul x19, x8, x8
49 ; CHECK-NEXT: mov x8, sp
50 ; CHECK-NEXT: sub x8, x8, x19
51 ; CHECK-NEXT: mov sp, x8
52 ; CHECK-NEXT: sub x20, x29, #16
53 ; CHECK-NEXT: stur x8, [x29, #-16]
54 ; CHECK-NEXT: sturh w19, [x29, #-8]
55 ; CHECK-NEXT: msr TPIDR2_EL0, x20
56 ; CHECK-NEXT: bl private_za_callee
57 ; CHECK-NEXT: smstart za
58 ; CHECK-NEXT: mrs x8, TPIDR2_EL0
59 ; CHECK-NEXT: sub x0, x29, #16
60 ; CHECK-NEXT: cbnz x8, .LBB1_2
61 ; CHECK-NEXT: // %bb.1:
62 ; CHECK-NEXT: bl __arm_tpidr2_restore
63 ; CHECK-NEXT: .LBB1_2:
64 ; CHECK-NEXT: msr TPIDR2_EL0, xzr
65 ; CHECK-NEXT: sturh w19, [x29, #-8]
66 ; CHECK-NEXT: msr TPIDR2_EL0, x20
67 ; CHECK-NEXT: bl private_za_callee
68 ; CHECK-NEXT: smstart za
69 ; CHECK-NEXT: mrs x8, TPIDR2_EL0
70 ; CHECK-NEXT: sub x0, x29, #16
71 ; CHECK-NEXT: cbnz x8, .LBB1_4
72 ; CHECK-NEXT: // %bb.3:
73 ; CHECK-NEXT: bl __arm_tpidr2_restore
74 ; CHECK-NEXT: .LBB1_4:
75 ; CHECK-NEXT: msr TPIDR2_EL0, xzr
76 ; CHECK-NEXT: mov sp, x29
77 ; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
78 ; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload
80 call void @private_za_callee()
81 call void @private_za_callee()
85 ; Test a call of an intrinsic that gets expanded to a library call.
86 define float @test_lazy_save_expanded_intrinsic(float %a) nounwind "aarch64_pstate_za_shared" {
87 ; CHECK-LABEL: test_lazy_save_expanded_intrinsic:
89 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
90 ; CHECK-NEXT: mov x29, sp
91 ; CHECK-NEXT: sub sp, sp, #16
92 ; CHECK-NEXT: rdsvl x8, #1
93 ; CHECK-NEXT: mov x9, sp
94 ; CHECK-NEXT: mul x8, x8, x8
95 ; CHECK-NEXT: sub x9, x9, x8
96 ; CHECK-NEXT: mov sp, x9
97 ; CHECK-NEXT: stur x9, [x29, #-16]
98 ; CHECK-NEXT: sub x9, x29, #16
99 ; CHECK-NEXT: sturh w8, [x29, #-8]
100 ; CHECK-NEXT: msr TPIDR2_EL0, x9
101 ; CHECK-NEXT: bl cosf
102 ; CHECK-NEXT: smstart za
103 ; CHECK-NEXT: mrs x8, TPIDR2_EL0
104 ; CHECK-NEXT: sub x0, x29, #16
105 ; CHECK-NEXT: cbnz x8, .LBB2_2
106 ; CHECK-NEXT: // %bb.1:
107 ; CHECK-NEXT: bl __arm_tpidr2_restore
108 ; CHECK-NEXT: .LBB2_2:
109 ; CHECK-NEXT: msr TPIDR2_EL0, xzr
110 ; CHECK-NEXT: mov sp, x29
111 ; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
113 %res = call float @llvm.cos.f32(float %a)
117 ; Test a combination of streaming-compatible -> normal call with lazy-save.
118 define void @test_lazy_save_and_conditional_smstart() nounwind "aarch64_pstate_za_shared" "aarch64_pstate_sm_compatible" {
119 ; CHECK-LABEL: test_lazy_save_and_conditional_smstart:
121 ; CHECK-NEXT: stp d15, d14, [sp, #-96]! // 16-byte Folded Spill
122 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
123 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
124 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
125 ; CHECK-NEXT: stp x29, x30, [sp, #64] // 16-byte Folded Spill
126 ; CHECK-NEXT: add x29, sp, #64
127 ; CHECK-NEXT: str x19, [sp, #80] // 8-byte Folded Spill
128 ; CHECK-NEXT: sub sp, sp, #16
129 ; CHECK-NEXT: rdsvl x8, #1
130 ; CHECK-NEXT: mov x9, sp
131 ; CHECK-NEXT: mul x8, x8, x8
132 ; CHECK-NEXT: sub x9, x9, x8
133 ; CHECK-NEXT: mov sp, x9
134 ; CHECK-NEXT: stur x9, [x29, #-80]
135 ; CHECK-NEXT: sub x9, x29, #80
136 ; CHECK-NEXT: sturh w8, [x29, #-72]
137 ; CHECK-NEXT: msr TPIDR2_EL0, x9
138 ; CHECK-NEXT: bl __arm_sme_state
139 ; CHECK-NEXT: and x19, x0, #0x1
140 ; CHECK-NEXT: tbz x19, #0, .LBB3_2
141 ; CHECK-NEXT: // %bb.1:
142 ; CHECK-NEXT: smstop sm
143 ; CHECK-NEXT: .LBB3_2:
144 ; CHECK-NEXT: bl private_za_callee
145 ; CHECK-NEXT: tbz x19, #0, .LBB3_4
146 ; CHECK-NEXT: // %bb.3:
147 ; CHECK-NEXT: smstart sm
148 ; CHECK-NEXT: .LBB3_4:
149 ; CHECK-NEXT: smstart za
150 ; CHECK-NEXT: mrs x8, TPIDR2_EL0
151 ; CHECK-NEXT: sub x0, x29, #80
152 ; CHECK-NEXT: cbnz x8, .LBB3_6
153 ; CHECK-NEXT: // %bb.5:
154 ; CHECK-NEXT: bl __arm_tpidr2_restore
155 ; CHECK-NEXT: .LBB3_6:
156 ; CHECK-NEXT: msr TPIDR2_EL0, xzr
157 ; CHECK-NEXT: sub sp, x29, #64
158 ; CHECK-NEXT: ldp x29, x30, [sp, #64] // 16-byte Folded Reload
159 ; CHECK-NEXT: ldr x19, [sp, #80] // 8-byte Folded Reload
160 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
161 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
162 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
163 ; CHECK-NEXT: ldp d15, d14, [sp], #96 // 16-byte Folded Reload
165 call void @private_za_callee()