1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-- -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
3 # RUN: llc -debugify-and-strip-all-safe -mtriple=aarch64-- -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
6 tracksRegLiveness: true
11 ; CHECK-LABEL: name: test_memcpy
12 ; CHECK: liveins: $w2, $x0, $x1
14 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
15 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
16 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
17 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
18 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
19 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
20 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
21 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
22 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
23 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
24 ; CHECK-NEXT: RET_ReallyLR
28 %3:_(s64) = G_ZEXT %2(s32)
29 G_MEMCPY %0(p0), %1(p0), %3(s64), 0 :: (store unknown-size), (load unknown-size)
34 name: test_memcpy_tail
35 tracksRegLiveness: true
38 liveins: $w2, $x0, $x1
40 ; CHECK-LABEL: name: test_memcpy_tail
41 ; CHECK: liveins: $w2, $x0, $x1
43 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
44 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
45 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
46 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
47 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
48 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
49 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
50 ; CHECK-NEXT: TCRETURNdi &memcpy, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0, implicit $x1, implicit $x2
54 %3:_(s64) = G_ZEXT %2(s32)
55 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
61 tracksRegLiveness: true
64 liveins: $w2, $x0, $x1
66 ; CHECK-LABEL: name: test_memmove
67 ; CHECK: liveins: $w2, $x0, $x1
69 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
70 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
71 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
72 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
73 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
74 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
75 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
76 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
77 ; CHECK-NEXT: BL &memmove, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
78 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
79 ; CHECK-NEXT: RET_ReallyLR
83 %3:_(s64) = G_ZEXT %2(s32)
84 G_MEMMOVE %0(p0), %1(p0), %3(s64), 0 :: (store unknown-size), (load unknown-size)
90 tracksRegLiveness: true
93 liveins: $w1, $w2, $x0
95 ; CHECK-LABEL: name: test_memset
96 ; CHECK: liveins: $w1, $w2, $x0
98 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
99 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
100 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
101 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
102 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
103 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
104 ; CHECK-NEXT: $w1 = COPY [[COPY1]](s32)
105 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
106 ; CHECK-NEXT: BL &memset, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $w1, implicit $x2
107 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
108 ; CHECK-NEXT: RET_ReallyLR
112 %3:_(s8) = G_TRUNC %1(s32)
113 %4:_(s64) = G_ZEXT %2(s32)
114 G_MEMSET %0(p0), %3(s8), %4(s64), 0 :: (store unknown-size)
120 tracksRegLiveness: true
123 liveins: $w2, $x0, $x1
125 ; CHECK-LABEL: name: no_tail_call
126 ; CHECK: liveins: $w2, $x0, $x1
128 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x1
129 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
130 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
131 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
132 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
133 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
134 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
135 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
136 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
137 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
138 ; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
139 ; CHECK-NEXT: RET_ReallyLR implicit $x0
143 %3:_(s64) = G_ZEXT %2(s32)
144 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
146 RET_ReallyLR implicit $x0
151 tracksRegLiveness: true
154 liveins: $w2, $x0, $x1
155 ; CHECK-LABEL: name: dont_tc_twice
156 ; CHECK: liveins: $w2, $x0, $x1
158 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
159 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
160 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
161 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
162 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
163 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
164 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
165 ; CHECK-NEXT: $x2 = COPY [[ZEXT]](s64)
166 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
167 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
168 ; CHECK-NEXT: TCRETURNdi &memset, 0, csr_aarch64_aapcs, implicit $sp
172 %4:_(s1) = G_CONSTANT i1 false
173 %3:_(s64) = G_ZEXT %2(s32)
174 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
175 TCRETURNdi &memset, 0, csr_aarch64_aapcs, implicit $sp
179 name: tail_with_copy_ret
181 tracksRegLiveness: true
183 - { id: 0, class: _ }
184 - { id: 1, class: _ }
185 - { id: 2, class: _ }
192 machineFunctionInfo: {}
195 liveins: $x0, $x1, $x2
197 ; CHECK-LABEL: name: tail_with_copy_ret
198 ; CHECK: liveins: $x0, $x1, $x2
200 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
201 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
202 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
203 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
204 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
205 ; CHECK-NEXT: $x2 = COPY [[COPY2]](s64)
206 ; CHECK-NEXT: TCRETURNdi &memcpy, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0, implicit $x1, implicit $x2
210 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
212 RET_ReallyLR implicit $x0
216 name: dont_tc_mismatched_copies
218 tracksRegLiveness: true
220 - { id: 0, class: _ }
221 - { id: 1, class: _ }
222 - { id: 2, class: _ }
229 machineFunctionInfo: {}
232 liveins: $x0, $x1, $x2
234 ; CHECK-LABEL: name: dont_tc_mismatched_copies
235 ; CHECK: liveins: $x0, $x1, $x2
237 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
238 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
239 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
240 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
241 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
242 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
243 ; CHECK-NEXT: $x2 = COPY [[COPY2]](s64)
244 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
245 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
246 ; CHECK-NEXT: $x1 = COPY [[COPY]](p0)
247 ; CHECK-NEXT: RET_ReallyLR implicit $x0
251 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
253 RET_ReallyLR implicit $x0
257 name: dont_tc_extra_copy
259 tracksRegLiveness: true
261 - { id: 0, class: _ }
262 - { id: 1, class: _ }
263 - { id: 2, class: _ }
270 machineFunctionInfo: {}
273 liveins: $x0, $x1, $x2
275 ; CHECK-LABEL: name: dont_tc_extra_copy
276 ; CHECK: liveins: $x0, $x1, $x2
278 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
279 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
280 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
281 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
282 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
283 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
284 ; CHECK-NEXT: $x2 = COPY [[COPY2]](s64)
285 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
286 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
287 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
288 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
289 ; CHECK-NEXT: RET_ReallyLR implicit $x0
293 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
296 RET_ReallyLR implicit $x0
300 name: dont_tc_mismatched_ret
302 tracksRegLiveness: true
304 - { id: 0, class: _ }
305 - { id: 1, class: _ }
306 - { id: 2, class: _ }
313 machineFunctionInfo: {}
316 liveins: $x0, $x1, $x2
318 ; CHECK-LABEL: name: dont_tc_mismatched_ret
319 ; CHECK: liveins: $x0, $x1, $x2
321 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x1
322 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
323 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
324 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
325 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
326 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
327 ; CHECK-NEXT: $x2 = COPY [[COPY2]](s64)
328 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
329 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
330 ; CHECK-NEXT: $x1 = COPY [[COPY]](p0)
331 ; CHECK-NEXT: RET_ReallyLR implicit $x0
335 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
337 RET_ReallyLR implicit $x0
341 name: dont_tc_ret_void_copy
343 tracksRegLiveness: true
345 - { id: 0, class: _ }
346 - { id: 1, class: _ }
347 - { id: 2, class: _ }
354 machineFunctionInfo: {}
357 liveins: $x0, $x1, $x2
359 ; CHECK-LABEL: name: dont_tc_ret_void_copy
360 ; CHECK: liveins: $x0, $x1, $x2
362 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
363 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
364 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
365 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
366 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
367 ; CHECK-NEXT: $x1 = COPY [[COPY1]](p0)
368 ; CHECK-NEXT: $x2 = COPY [[COPY2]](s64)
369 ; CHECK-NEXT: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
370 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
371 ; CHECK-NEXT: $x0 = COPY [[COPY]](p0)
372 ; CHECK-NEXT: RET_ReallyLR
376 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))