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
13 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
14 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
15 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
16 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
17 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
18 ; CHECK: $x0 = COPY [[COPY]](p0)
19 ; CHECK: $x1 = COPY [[COPY1]](p0)
20 ; CHECK: $x2 = COPY [[ZEXT]](s64)
21 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
22 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
27 %3:_(s64) = G_ZEXT %2(s32)
28 G_MEMCPY %0(p0), %1(p0), %3(s64), 0 :: (store unknown-size), (load unknown-size)
33 name: test_memcpy_tail
34 tracksRegLiveness: true
37 liveins: $w2, $x0, $x1
39 ; CHECK-LABEL: name: test_memcpy_tail
40 ; CHECK: liveins: $w2, $x0, $x1
41 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
42 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
43 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
44 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
45 ; CHECK: $x0 = COPY [[COPY]](p0)
46 ; CHECK: $x1 = COPY [[COPY1]](p0)
47 ; CHECK: $x2 = COPY [[ZEXT]](s64)
48 ; CHECK: TCRETURNdi &memcpy, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0, implicit $x1, implicit $x2
52 %3:_(s64) = G_ZEXT %2(s32)
53 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
59 tracksRegLiveness: true
62 liveins: $w2, $x0, $x1
64 ; CHECK-LABEL: name: test_memmove
65 ; CHECK: liveins: $w2, $x0, $x1
66 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
67 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
68 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
69 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
70 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
71 ; CHECK: $x0 = COPY [[COPY]](p0)
72 ; CHECK: $x1 = COPY [[COPY1]](p0)
73 ; CHECK: $x2 = COPY [[ZEXT]](s64)
74 ; CHECK: BL &memmove, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
75 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
80 %3:_(s64) = G_ZEXT %2(s32)
81 G_MEMMOVE %0(p0), %1(p0), %3(s64), 0 :: (store unknown-size), (load unknown-size)
87 tracksRegLiveness: true
90 liveins: $w1, $w2, $x0
92 ; CHECK-LABEL: name: test_memset
93 ; CHECK: liveins: $w1, $w2, $x0
94 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
95 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
96 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
97 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
98 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
99 ; CHECK: $x0 = COPY [[COPY]](p0)
100 ; CHECK: $w1 = COPY [[COPY1]](s32)
101 ; CHECK: $x2 = COPY [[ZEXT]](s64)
102 ; CHECK: BL &memset, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $w1, implicit $x2
103 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
104 ; CHECK: RET_ReallyLR
108 %3:_(s8) = G_TRUNC %1(s32)
109 %4:_(s64) = G_ZEXT %2(s32)
110 G_MEMSET %0(p0), %3(s8), %4(s64), 0 :: (store unknown-size)
116 tracksRegLiveness: true
119 liveins: $w2, $x0, $x1
121 ; CHECK-LABEL: name: no_tail_call
122 ; CHECK: liveins: $w2, $x0, $x1
123 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x1
124 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
125 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
126 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
127 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
128 ; CHECK: $x0 = COPY [[COPY]](p0)
129 ; CHECK: $x1 = COPY [[COPY1]](p0)
130 ; CHECK: $x2 = COPY [[ZEXT]](s64)
131 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
132 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
133 ; CHECK: $x0 = COPY [[ZEXT]](s64)
134 ; CHECK: RET_ReallyLR implicit $x0
138 %3:_(s64) = G_ZEXT %2(s32)
139 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
141 RET_ReallyLR implicit $x0
146 tracksRegLiveness: true
149 liveins: $w2, $x0, $x1
150 ; CHECK-LABEL: name: dont_tc_twice
151 ; CHECK: liveins: $w2, $x0, $x1
152 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
153 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
154 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
155 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY2]](s32)
156 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
157 ; CHECK: $x0 = COPY [[COPY]](p0)
158 ; CHECK: $x1 = COPY [[COPY1]](p0)
159 ; CHECK: $x2 = COPY [[ZEXT]](s64)
160 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
161 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
162 ; CHECK: TCRETURNdi &memset, 0, csr_aarch64_aapcs, implicit $sp
166 %4:_(s1) = G_CONSTANT i1 false
167 %3:_(s64) = G_ZEXT %2(s32)
168 G_MEMCPY %0(p0), %1(p0), %3(s64), 1 :: (store unknown-size), (load unknown-size)
169 TCRETURNdi &memset, 0, csr_aarch64_aapcs, implicit $sp
173 name: tail_with_copy_ret
175 tracksRegLiveness: true
177 - { id: 0, class: _ }
178 - { id: 1, class: _ }
179 - { id: 2, class: _ }
186 machineFunctionInfo: {}
189 liveins: $x0, $x1, $x2
191 ; CHECK-LABEL: name: tail_with_copy_ret
192 ; CHECK: liveins: $x0, $x1, $x2
193 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
194 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
195 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
196 ; CHECK: $x0 = COPY [[COPY]](p0)
197 ; CHECK: $x1 = COPY [[COPY1]](p0)
198 ; CHECK: $x2 = COPY [[COPY2]](s64)
199 ; CHECK: TCRETURNdi &memcpy, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0, implicit $x1, implicit $x2
203 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
205 RET_ReallyLR implicit $x0
209 name: dont_tc_mismatched_copies
211 tracksRegLiveness: true
213 - { id: 0, class: _ }
214 - { id: 1, class: _ }
215 - { id: 2, class: _ }
222 machineFunctionInfo: {}
225 liveins: $x0, $x1, $x2
227 ; CHECK-LABEL: name: dont_tc_mismatched_copies
228 ; CHECK: liveins: $x0, $x1, $x2
229 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
230 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
231 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
232 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
233 ; CHECK: $x0 = COPY [[COPY]](p0)
234 ; CHECK: $x1 = COPY [[COPY1]](p0)
235 ; CHECK: $x2 = COPY [[COPY2]](s64)
236 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
237 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
238 ; CHECK: $x1 = COPY [[COPY]](p0)
239 ; CHECK: RET_ReallyLR implicit $x0
243 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
245 RET_ReallyLR implicit $x0
249 name: dont_tc_extra_copy
251 tracksRegLiveness: true
253 - { id: 0, class: _ }
254 - { id: 1, class: _ }
255 - { id: 2, class: _ }
262 machineFunctionInfo: {}
265 liveins: $x0, $x1, $x2
267 ; CHECK-LABEL: name: dont_tc_extra_copy
268 ; CHECK: liveins: $x0, $x1, $x2
269 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
270 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
271 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
272 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
273 ; CHECK: $x0 = COPY [[COPY]](p0)
274 ; CHECK: $x1 = COPY [[COPY1]](p0)
275 ; CHECK: $x2 = COPY [[COPY2]](s64)
276 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
277 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
278 ; CHECK: $x0 = COPY [[COPY]](p0)
279 ; CHECK: $x0 = COPY [[COPY]](p0)
280 ; CHECK: RET_ReallyLR implicit $x0
284 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
287 RET_ReallyLR implicit $x0
291 name: dont_tc_mismatched_ret
293 tracksRegLiveness: true
295 - { id: 0, class: _ }
296 - { id: 1, class: _ }
297 - { id: 2, class: _ }
304 machineFunctionInfo: {}
307 liveins: $x0, $x1, $x2
309 ; CHECK-LABEL: name: dont_tc_mismatched_ret
310 ; CHECK: liveins: $x0, $x1, $x2
311 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x1
312 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
313 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
314 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
315 ; CHECK: $x0 = COPY [[COPY]](p0)
316 ; CHECK: $x1 = COPY [[COPY1]](p0)
317 ; CHECK: $x2 = COPY [[COPY2]](s64)
318 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
319 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
320 ; CHECK: $x1 = COPY [[COPY]](p0)
321 ; CHECK: RET_ReallyLR implicit $x0
325 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))
327 RET_ReallyLR implicit $x0
331 name: dont_tc_ret_void_copy
333 tracksRegLiveness: true
335 - { id: 0, class: _ }
336 - { id: 1, class: _ }
337 - { id: 2, class: _ }
344 machineFunctionInfo: {}
347 liveins: $x0, $x1, $x2
349 ; CHECK-LABEL: name: dont_tc_ret_void_copy
350 ; CHECK: liveins: $x0, $x1, $x2
351 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
352 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
353 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
354 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
355 ; CHECK: $x0 = COPY [[COPY]](p0)
356 ; CHECK: $x1 = COPY [[COPY1]](p0)
357 ; CHECK: $x2 = COPY [[COPY2]](s64)
358 ; CHECK: BL &memcpy, csr_aarch64_aapcs_thisreturn, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1, implicit $x2
359 ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
360 ; CHECK: $x0 = COPY [[COPY]](p0)
361 ; CHECK: RET_ReallyLR
365 G_MEMCPY %0(p0), %1(p0), %2(s64), 1 :: (store (s8)), (load (s8))