1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme -start-after=simplifycfg -enable-tail-merge=false -verify-machineinstrs < %s | FileCheck %s
4 declare void @normal_callee();
5 declare void @streaming_callee() "aarch64_pstate_sm_enabled";
6 declare void @streaming_compatible_callee() "aarch64_pstate_sm_compatible";
8 define void @locally_streaming_caller_streaming_callee() "aarch64_pstate_sm_body" nounwind {
9 ; CHECK-LABEL: locally_streaming_caller_streaming_callee:
11 ; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
12 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
13 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
14 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
15 ; CHECK-NEXT: str x30, [sp, #64] // 8-byte Folded Spill
16 ; CHECK-NEXT: smstart sm
17 ; CHECK-NEXT: bl streaming_compatible_callee
18 ; CHECK-NEXT: bl streaming_compatible_callee
19 ; CHECK-NEXT: smstop sm
20 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
21 ; CHECK-NEXT: ldr x30, [sp, #64] // 8-byte Folded Reload
22 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
23 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
24 ; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
27 call void @streaming_compatible_callee();
28 call void @streaming_compatible_callee();
32 ; Test that a streaming body and streaming interface, no smstart/smstop are emitted,
33 ; because the function already is in streaming mode upon entry.
34 define void @streaming_and_locally_streaming_caller_streaming_callee() "aarch64_pstate_sm_enabled" "aarch64_pstate_sm_body" nounwind {
35 ; CHECK-LABEL: streaming_and_locally_streaming_caller_streaming_callee:
37 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
38 ; CHECK-NEXT: bl streaming_callee
39 ; CHECK-NEXT: bl streaming_callee
40 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
42 call void @streaming_callee();
43 call void @streaming_callee();
47 define void @locally_streaming_multiple_exit(i64 %cond) "aarch64_pstate_sm_body" nounwind {
48 ; CHECK-LABEL: locally_streaming_multiple_exit:
49 ; CHECK: // %bb.0: // %entry
50 ; CHECK-NEXT: stp d15, d14, [sp, #-64]! // 16-byte Folded Spill
51 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
52 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
53 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
54 ; CHECK-NEXT: smstart sm
55 ; CHECK-NEXT: cmp x0, #1
56 ; CHECK-NEXT: b.ne .LBB2_2
57 ; CHECK-NEXT: // %bb.1: // %if.else
58 ; CHECK-NEXT: smstop sm
59 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
60 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
61 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
62 ; CHECK-NEXT: ldp d15, d14, [sp], #64 // 16-byte Folded Reload
64 ; CHECK-NEXT: .LBB2_2: // %if.end
65 ; CHECK-NEXT: smstop sm
66 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
67 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
68 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
69 ; CHECK-NEXT: ldp d15, d14, [sp], #64 // 16-byte Folded Reload
73 %tobool = icmp eq i64 %cond, 1
74 br i1 %tobool, label %if.else, label %if.end
83 ; Do a fixed-width vector add on a NEON vector.
85 ; * Incoming vector in v0.d isn't clobbered by the change in streaming mode.
86 ; * Result vector is correctly preserved after smstop.
87 define <2 x i64> @locally_streaming_caller_no_callee(<2 x i64> %a) "aarch64_pstate_sm_body" nounwind {
88 ; CHECK-LABEL: locally_streaming_caller_no_callee:
90 ; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
91 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
92 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
93 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
94 ; CHECK-NEXT: str x29, [sp, #64] // 8-byte Folded Spill
95 ; CHECK-NEXT: addsvl sp, sp, #-1
96 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
97 ; CHECK-NEXT: str z0, [sp] // 16-byte Folded Spill
98 ; CHECK-NEXT: smstart sm
99 ; CHECK-NEXT: index z0.d, #0, #1
100 ; CHECK-NEXT: ldr z1, [sp] // 16-byte Folded Reload
101 ; CHECK-NEXT: add z0.d, z0.d, z1.d
102 ; CHECK-NEXT: add z0.d, z0.d, #41 // =0x29
103 ; CHECK-NEXT: str z0, [sp] // 16-byte Folded Spill
104 ; CHECK-NEXT: smstop sm
105 ; CHECK-NEXT: ldr z0, [sp] // 16-byte Folded Reload
106 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
107 ; CHECK-NEXT: addsvl sp, sp, #1
108 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
109 ; CHECK-NEXT: ldr x29, [sp, #64] // 8-byte Folded Reload
110 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
111 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
112 ; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
115 %add = add <2 x i64> %a, <i64 41, i64 42>;
119 ; Test that we use the interface (not the function's body) to determine what
120 ; streaming-mode to enter the callee. In this case the interface is normal, so
121 ; pstate.sm must be 0 on entry and is 0 upon return from the callee.
122 define void @locally_streaming_caller_locally_streaming_callee() "aarch64_pstate_sm_body" nounwind {
123 ; CHECK-LABEL: locally_streaming_caller_locally_streaming_callee:
125 ; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
126 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
127 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
128 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
129 ; CHECK-NEXT: str x30, [sp, #64] // 8-byte Folded Spill
130 ; CHECK-NEXT: smstart sm
131 ; CHECK-NEXT: smstop sm
132 ; CHECK-NEXT: bl locally_streaming_caller_streaming_callee
133 ; CHECK-NEXT: smstart sm
134 ; CHECK-NEXT: smstop sm
135 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
136 ; CHECK-NEXT: ldr x30, [sp, #64] // 8-byte Folded Reload
137 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
138 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
139 ; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
142 call void @locally_streaming_caller_streaming_callee();
147 ; Test that a locally streaming function correctly retains the
148 ; argument/result registers, because smstart/smstop instructions that are
149 ; inserted to implement the arm_locally_streaming attribute thrashes the
150 ; vector register contents.
153 define <2 x i64> @locally_streaming_caller_compatible_callee_vec_args_ret(<2 x i64> %a) "aarch64_pstate_sm_body" nounwind {
154 ; CHECK-LABEL: locally_streaming_caller_compatible_callee_vec_args_ret:
156 ; CHECK-NEXT: sub sp, sp, #96
157 ; CHECK-NEXT: stp d15, d14, [sp, #16] // 16-byte Folded Spill
158 ; CHECK-NEXT: stp d13, d12, [sp, #32] // 16-byte Folded Spill
159 ; CHECK-NEXT: stp d11, d10, [sp, #48] // 16-byte Folded Spill
160 ; CHECK-NEXT: stp d9, d8, [sp, #64] // 16-byte Folded Spill
161 ; CHECK-NEXT: str x30, [sp, #80] // 8-byte Folded Spill
162 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
163 ; CHECK-NEXT: smstart sm
164 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
165 ; CHECK-NEXT: bl streaming_compatible_callee_vec_args_ret
166 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
167 ; CHECK-NEXT: smstop sm
168 ; CHECK-NEXT: ldp d9, d8, [sp, #64] // 16-byte Folded Reload
169 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
170 ; CHECK-NEXT: ldp d11, d10, [sp, #48] // 16-byte Folded Reload
171 ; CHECK-NEXT: ldr x30, [sp, #80] // 8-byte Folded Reload
172 ; CHECK-NEXT: ldp d13, d12, [sp, #32] // 16-byte Folded Reload
173 ; CHECK-NEXT: ldp d15, d14, [sp, #16] // 16-byte Folded Reload
174 ; CHECK-NEXT: add sp, sp, #96
176 %res = call <2 x i64> @streaming_compatible_callee_vec_args_ret(<2 x i64> %a) "aarch64_pstate_sm_compatible"
180 declare <2 x i64> @streaming_compatible_callee_vec_args_ret(<2 x i64>) "aarch64_pstate_sm_compatible"
182 define {<2 x i64>, <2 x i64>} @locally_streaming_caller_compatible_callee_struct_arg_ret({<2 x i64>, <2 x i64>} %arg) "aarch64_pstate_sm_body" nounwind {
183 ; CHECK-LABEL: locally_streaming_caller_compatible_callee_struct_arg_ret:
185 ; CHECK-NEXT: sub sp, sp, #112
186 ; CHECK-NEXT: stp d15, d14, [sp, #32] // 16-byte Folded Spill
187 ; CHECK-NEXT: stp d13, d12, [sp, #48] // 16-byte Folded Spill
188 ; CHECK-NEXT: stp d11, d10, [sp, #64] // 16-byte Folded Spill
189 ; CHECK-NEXT: stp d9, d8, [sp, #80] // 16-byte Folded Spill
190 ; CHECK-NEXT: str x30, [sp, #96] // 8-byte Folded Spill
191 ; CHECK-NEXT: str q1, [sp, #16] // 16-byte Folded Spill
192 ; CHECK-NEXT: smstart sm
193 ; CHECK-NEXT: ldr q0, [sp, #16] // 16-byte Folded Reload
194 ; CHECK-NEXT: bl streaming_compatible_callee_vec_arg_struct_ret
195 ; CHECK-NEXT: stp q1, q0, [sp] // 32-byte Folded Spill
196 ; CHECK-NEXT: smstop sm
197 ; CHECK-NEXT: ldp q1, q0, [sp] // 32-byte Folded Reload
198 ; CHECK-NEXT: ldr x30, [sp, #96] // 8-byte Folded Reload
199 ; CHECK-NEXT: ldp d9, d8, [sp, #80] // 16-byte Folded Reload
200 ; CHECK-NEXT: ldp d11, d10, [sp, #64] // 16-byte Folded Reload
201 ; CHECK-NEXT: ldp d13, d12, [sp, #48] // 16-byte Folded Reload
202 ; CHECK-NEXT: ldp d15, d14, [sp, #32] // 16-byte Folded Reload
203 ; CHECK-NEXT: add sp, sp, #112
205 %v1.arg = extractvalue {<2 x i64>, <2 x i64>} %arg, 1
206 %res = call {<2 x i64>, <2 x i64>} @streaming_compatible_callee_vec_arg_struct_ret(<2 x i64> %v1.arg) "aarch64_pstate_sm_compatible"
207 ret {<2 x i64>, <2 x i64>} %res;
210 declare {<2 x i64>, <2 x i64>} @streaming_compatible_callee_vec_arg_struct_ret(<2 x i64>) "aarch64_pstate_sm_compatible"
212 ; Test that we use `addsvl` for allocating any stack space for locals before `smstart`,
213 ; such that the correct amount of stack space is allocated.
214 define void @locally_streaming_caller_alloca() nounwind "aarch64_pstate_sm_body" {
215 ; CHECK-LABEL: locally_streaming_caller_alloca:
217 ; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
218 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
219 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
220 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
221 ; CHECK-NEXT: stp x29, x30, [sp, #64] // 16-byte Folded Spill
222 ; CHECK-NEXT: addsvl sp, sp, #-1
223 ; CHECK-NEXT: smstart sm
224 ; CHECK-NEXT: mov x0, sp
225 ; CHECK-NEXT: bl use_ptr
226 ; CHECK-NEXT: smstop sm
227 ; CHECK-NEXT: addsvl sp, sp, #1
228 ; CHECK-NEXT: ldp x29, x30, [sp, #64] // 16-byte Folded Reload
229 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
230 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
231 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
232 ; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
234 %alloca = alloca <vscale x 4 x i32>
235 call void @use_ptr(ptr %alloca) "aarch64_pstate_sm_compatible"
239 declare void @use_ptr(ptr) "aarch64_pstate_sm_compatible"
241 define double @call_to_intrinsic_without_chain(double %x) nounwind "aarch64_pstate_sm_body" {
242 ; CHECK-LABEL: call_to_intrinsic_without_chain:
243 ; CHECK: // %bb.0: // %entry
244 ; CHECK-NEXT: sub sp, sp, #96
245 ; CHECK-NEXT: stp d15, d14, [sp, #16] // 16-byte Folded Spill
246 ; CHECK-NEXT: stp d13, d12, [sp, #32] // 16-byte Folded Spill
247 ; CHECK-NEXT: stp d11, d10, [sp, #48] // 16-byte Folded Spill
248 ; CHECK-NEXT: stp d9, d8, [sp, #64] // 16-byte Folded Spill
249 ; CHECK-NEXT: str x30, [sp, #80] // 8-byte Folded Spill
250 ; CHECK-NEXT: str d0, [sp, #8] // 8-byte Folded Spill
251 ; CHECK-NEXT: smstart sm
252 ; CHECK-NEXT: smstop sm
253 ; CHECK-NEXT: ldr d0, [sp, #8] // 8-byte Folded Reload
255 ; CHECK-NEXT: str d0, [sp, #8] // 8-byte Folded Spill
256 ; CHECK-NEXT: smstart sm
257 ; CHECK-NEXT: smstop sm
258 ; CHECK-NEXT: ldp d9, d8, [sp, #64] // 16-byte Folded Reload
259 ; CHECK-NEXT: ldr d0, [sp, #8] // 8-byte Folded Reload
260 ; CHECK-NEXT: ldp d11, d10, [sp, #48] // 16-byte Folded Reload
261 ; CHECK-NEXT: ldr x30, [sp, #80] // 8-byte Folded Reload
262 ; CHECK-NEXT: ldp d13, d12, [sp, #32] // 16-byte Folded Reload
263 ; CHECK-NEXT: ldp d15, d14, [sp, #16] // 16-byte Folded Reload
264 ; CHECK-NEXT: add sp, sp, #96
267 %0 = call fast double @llvm.cos.f64(double %x)
271 declare double @llvm.cos.f64(double)
274 define float @test_arg_survives_loop(float %arg, i32 %N) nounwind "aarch64_pstate_sm_body" {
275 ; CHECK-LABEL: test_arg_survives_loop:
276 ; CHECK: // %bb.0: // %entry
277 ; CHECK-NEXT: sub sp, sp, #80
278 ; CHECK-NEXT: stp d15, d14, [sp, #16] // 16-byte Folded Spill
279 ; CHECK-NEXT: stp d13, d12, [sp, #32] // 16-byte Folded Spill
280 ; CHECK-NEXT: stp d11, d10, [sp, #48] // 16-byte Folded Spill
281 ; CHECK-NEXT: stp d9, d8, [sp, #64] // 16-byte Folded Spill
282 ; CHECK-NEXT: str s0, [sp, #12] // 4-byte Folded Spill
283 ; CHECK-NEXT: smstart sm
284 ; CHECK-NEXT: .LBB9_1: // %for.body
285 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
286 ; CHECK-NEXT: subs w0, w0, #1
287 ; CHECK-NEXT: b.ne .LBB9_1
288 ; CHECK-NEXT: // %bb.2: // %for.cond.cleanup
289 ; CHECK-NEXT: fmov s0, #1.00000000
290 ; CHECK-NEXT: ldr s1, [sp, #12] // 4-byte Folded Reload
291 ; CHECK-NEXT: fadd s0, s1, s0
292 ; CHECK-NEXT: str s0, [sp, #12] // 4-byte Folded Spill
293 ; CHECK-NEXT: smstop sm
294 ; CHECK-NEXT: ldp d9, d8, [sp, #64] // 16-byte Folded Reload
295 ; CHECK-NEXT: ldr s0, [sp, #12] // 4-byte Folded Reload
296 ; CHECK-NEXT: ldp d11, d10, [sp, #48] // 16-byte Folded Reload
297 ; CHECK-NEXT: ldp d13, d12, [sp, #32] // 16-byte Folded Reload
298 ; CHECK-NEXT: ldp d15, d14, [sp, #16] // 16-byte Folded Reload
299 ; CHECK-NEXT: add sp, sp, #80
305 %i.02 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
306 %inc = add nuw nsw i32 %i.02, 1
307 %exitcond.not = icmp eq i32 %inc, %N
308 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
311 %add = fadd float %arg, 1.000000e+00
316 define void @disable_tailcallopt() "aarch64_pstate_sm_body" nounwind {
317 ; CHECK-LABEL: disable_tailcallopt:
319 ; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
320 ; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
321 ; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
322 ; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
323 ; CHECK-NEXT: str x30, [sp, #64] // 8-byte Folded Spill
324 ; CHECK-NEXT: smstart sm
325 ; CHECK-NEXT: bl streaming_compatible_callee
326 ; CHECK-NEXT: smstop sm
327 ; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
328 ; CHECK-NEXT: ldr x30, [sp, #64] // 8-byte Folded Reload
329 ; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
330 ; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
331 ; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
333 tail call void @streaming_compatible_callee();