1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=aarch64-- -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
3
4--- |
5  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6
7  define void @load_s64_gpr(i64* %addr) { ret void }
8  define void @load_s32_gpr(i32* %addr) { ret void }
9  define void @load_s16_gpr_anyext(i16* %addr) { ret void }
10  define void @load_s16_gpr(i16* %addr) { ret void }
11  define void @load_s8_gpr_anyext(i8* %addr) { ret void }
12  define void @load_s8_gpr(i8* %addr) { ret void }
13
14  define void @load_fi_s64_gpr() {
15    %ptr0 = alloca i64
16    ret void
17  }
18
19  define void @load_gep_128_s64_gpr(i64* %addr) { ret void }
20  define void @load_gep_512_s32_gpr(i32* %addr) { ret void }
21  define void @load_gep_64_s16_gpr(i16* %addr) { ret void }
22  define void @load_gep_1_s8_gpr(i8* %addr) { ret void }
23
24  define void @load_s64_fpr(i64* %addr) { ret void }
25  define void @load_s32_fpr(i32* %addr) { ret void }
26  define void @load_s16_fpr(i16* %addr) { ret void }
27  define void @load_s8_fpr(i8* %addr) { ret void }
28
29  define void @load_gep_8_s64_fpr(i64* %addr) { ret void }
30  define void @load_gep_16_s32_fpr(i32* %addr) { ret void }
31  define void @load_gep_64_s16_fpr(i16* %addr) { ret void }
32  define void @load_gep_32_s8_fpr(i8* %addr) { ret void }
33
34  define void @load_v2s32(i64 *%addr) { ret void }
35...
36
37---
38name:            load_s64_gpr
39legalized:       true
40regBankSelected: true
41
42registers:
43  - { id: 0, class: gpr }
44  - { id: 1, class: gpr }
45
46body:             |
47  bb.0:
48    liveins: $x0
49
50    ; CHECK-LABEL: name: load_s64_gpr
51    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
52    ; CHECK: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui [[COPY]], 0 :: (load 8 from %ir.addr)
53    ; CHECK: $x0 = COPY [[LDRXui]]
54    %0(p0) = COPY $x0
55    %1(s64) = G_LOAD  %0 :: (load 8 from %ir.addr)
56    $x0 = COPY %1(s64)
57...
58
59---
60name:            load_s32_gpr
61legalized:       true
62regBankSelected: true
63
64registers:
65  - { id: 0, class: gpr }
66  - { id: 1, class: gpr }
67
68body:             |
69  bb.0:
70    liveins: $x0
71
72    ; CHECK-LABEL: name: load_s32_gpr
73    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
74    ; CHECK: [[LDRWui:%[0-9]+]]:gpr32 = LDRWui [[COPY]], 0 :: (load 4 from %ir.addr)
75    ; CHECK: $w0 = COPY [[LDRWui]]
76    %0(p0) = COPY $x0
77    %1(s32) = G_LOAD  %0 :: (load 4 from %ir.addr)
78    $w0 = COPY %1(s32)
79...
80
81---
82name:            load_s16_gpr_anyext
83legalized:       true
84regBankSelected: true
85
86body:             |
87  bb.0:
88    liveins: $x0
89
90    ; CHECK-LABEL: name: load_s16_gpr_anyext
91    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
92    ; CHECK: [[LDRHHui:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 0 :: (load 2 from %ir.addr)
93    ; CHECK: $w0 = COPY [[LDRHHui]]
94    %0:gpr(p0) = COPY $x0
95    %1:gpr(s32) = G_LOAD  %0 :: (load 2 from %ir.addr)
96    $w0 = COPY %1(s32)
97...
98
99---
100name:            load_s16_gpr
101legalized:       true
102regBankSelected: true
103
104registers:
105  - { id: 0, class: gpr }
106  - { id: 1, class: gpr }
107
108body:             |
109  bb.0:
110    liveins: $x0
111
112    ; CHECK-LABEL: name: load_s16_gpr
113    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
114    ; CHECK: [[LDRHHui:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 0 :: (load 2 from %ir.addr)
115    ; CHECK: [[T0:%[0-9]+]]:gpr32all = COPY [[LDRHHui]]
116    ; CHECK: $w0 = COPY [[T0]]
117    %0(p0) = COPY $x0
118    %1(s16) = G_LOAD  %0 :: (load 2 from %ir.addr)
119    %2:gpr(s32) = G_ANYEXT %1
120    $w0 = COPY %2(s32)
121...
122
123---
124name:            load_s8_gpr_anyext
125legalized:       true
126regBankSelected: true
127
128body:             |
129  bb.0:
130    liveins: $x0
131
132    ; CHECK-LABEL: name: load_s8_gpr
133    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
134    ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load 1 from %ir.addr)
135    ; CHECK: $w0 = COPY [[LDRBBui]]
136    %0:gpr(p0) = COPY $x0
137    %1:gpr(s32) = G_LOAD  %0 :: (load 1 from %ir.addr)
138    $w0 = COPY %1(s32)
139...
140
141---
142name:            load_s8_gpr
143legalized:       true
144regBankSelected: true
145
146registers:
147  - { id: 0, class: gpr }
148  - { id: 1, class: gpr }
149
150body:             |
151  bb.0:
152    liveins: $x0
153
154    ; CHECK-LABEL: name: load_s8_gpr
155    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
156    ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load 1 from %ir.addr)
157    ; CHECK: [[T0:%[0-9]+]]:gpr32all = COPY [[LDRBBui]]
158    ; CHECK: $w0 = COPY [[T0]]
159    %0(p0) = COPY $x0
160    %1(s8) = G_LOAD  %0 :: (load 1 from %ir.addr)
161    %2:gpr(s32) = G_ANYEXT %1
162    $w0 = COPY %2(s32)
163...
164
165---
166name:            load_fi_s64_gpr
167legalized:       true
168regBankSelected: true
169
170registers:
171  - { id: 0, class: gpr }
172  - { id: 1, class: gpr }
173
174stack:
175  - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
176
177body:             |
178  bb.0:
179    liveins: $x0
180
181    ; CHECK-LABEL: name: load_fi_s64_gpr
182    ; CHECK: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui %stack.0.ptr0, 0 :: (load 8)
183    ; CHECK: $x0 = COPY [[LDRXui]]
184    %0(p0) = G_FRAME_INDEX %stack.0.ptr0
185    %1(s64) = G_LOAD %0 :: (load 8)
186    $x0 = COPY %1(s64)
187...
188
189---
190name:            load_gep_128_s64_gpr
191legalized:       true
192regBankSelected: true
193
194registers:
195  - { id: 0, class: gpr }
196  - { id: 1, class: gpr }
197  - { id: 2, class: gpr }
198  - { id: 3, class: gpr }
199
200body:             |
201  bb.0:
202    liveins: $x0
203
204    ; CHECK-LABEL: name: load_gep_128_s64_gpr
205    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
206    ; CHECK: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui [[COPY]], 16 :: (load 8 from %ir.addr)
207    ; CHECK: $x0 = COPY [[LDRXui]]
208    %0(p0) = COPY $x0
209    %1(s64) = G_CONSTANT i64 128
210    %2(p0) = G_GEP %0, %1
211    %3(s64) = G_LOAD %2 :: (load 8 from %ir.addr)
212    $x0 = COPY %3
213...
214
215---
216name:            load_gep_512_s32_gpr
217legalized:       true
218regBankSelected: true
219
220registers:
221  - { id: 0, class: gpr }
222  - { id: 1, class: gpr }
223  - { id: 2, class: gpr }
224  - { id: 3, class: gpr }
225
226body:             |
227  bb.0:
228    liveins: $x0
229
230    ; CHECK-LABEL: name: load_gep_512_s32_gpr
231    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
232    ; CHECK: [[LDRWui:%[0-9]+]]:gpr32 = LDRWui [[COPY]], 128 :: (load 4 from %ir.addr)
233    ; CHECK: $w0 = COPY [[LDRWui]]
234    %0(p0) = COPY $x0
235    %1(s64) = G_CONSTANT i64 512
236    %2(p0) = G_GEP %0, %1
237    %3(s32) = G_LOAD %2 :: (load 4 from %ir.addr)
238    $w0 = COPY %3
239...
240
241---
242name:            load_gep_64_s16_gpr
243legalized:       true
244regBankSelected: true
245
246registers:
247  - { id: 0, class: gpr }
248  - { id: 1, class: gpr }
249  - { id: 2, class: gpr }
250  - { id: 3, class: gpr }
251
252body:             |
253  bb.0:
254    liveins: $x0
255
256    ; CHECK-LABEL: name: load_gep_64_s16_gpr
257    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
258    ; CHECK: [[LDRHHui:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 32 :: (load 2 from %ir.addr)
259    ; CHECK: [[T0:%[0-9]+]]:gpr32all = COPY [[LDRHHui]]
260    ; CHECK: $w0 = COPY [[T0]]
261    %0(p0) = COPY $x0
262    %1(s64) = G_CONSTANT i64 64
263    %2(p0) = G_GEP %0, %1
264    %3(s16) = G_LOAD %2 :: (load 2 from %ir.addr)
265    %4:gpr(s32) = G_ANYEXT %3
266    $w0 = COPY %4
267...
268
269---
270name:            load_gep_1_s8_gpr
271legalized:       true
272regBankSelected: true
273
274registers:
275  - { id: 0, class: gpr }
276  - { id: 1, class: gpr }
277  - { id: 2, class: gpr }
278  - { id: 3, class: gpr }
279
280body:             |
281  bb.0:
282    liveins: $x0
283
284    ; CHECK-LABEL: name: load_gep_1_s8_gpr
285    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
286    ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 1 :: (load 1 from %ir.addr)
287    ; CHECK: [[T0:%[0-9]+]]:gpr32all = COPY [[LDRBBui]]
288    ; CHECK: $w0 = COPY [[T0]]
289    %0(p0) = COPY $x0
290    %1(s64) = G_CONSTANT i64 1
291    %2(p0) = G_GEP %0, %1
292    %3(s8) = G_LOAD %2 :: (load 1 from %ir.addr)
293    %4:gpr(s32) = G_ANYEXT %3
294    $w0 = COPY %4
295...
296
297---
298name:            load_s64_fpr
299legalized:       true
300regBankSelected: true
301
302registers:
303  - { id: 0, class: gpr }
304  - { id: 1, class: fpr }
305
306body:             |
307  bb.0:
308    liveins: $x0
309
310    ; CHECK-LABEL: name: load_s64_fpr
311    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
312    ; CHECK: [[LDRDui:%[0-9]+]]:fpr64 = LDRDui [[COPY]], 0 :: (load 8 from %ir.addr)
313    ; CHECK: $d0 = COPY [[LDRDui]]
314    %0(p0) = COPY $x0
315    %1(s64) = G_LOAD  %0 :: (load 8 from %ir.addr)
316    $d0 = COPY %1(s64)
317...
318
319---
320name:            load_s32_fpr
321legalized:       true
322regBankSelected: true
323
324registers:
325  - { id: 0, class: gpr }
326  - { id: 1, class: fpr }
327
328body:             |
329  bb.0:
330    liveins: $x0
331
332    ; CHECK-LABEL: name: load_s32_fpr
333    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
334    ; CHECK: [[LDRSui:%[0-9]+]]:fpr32 = LDRSui [[COPY]], 0 :: (load 4 from %ir.addr)
335    ; CHECK: $s0 = COPY [[LDRSui]]
336    %0(p0) = COPY $x0
337    %1(s32) = G_LOAD  %0 :: (load 4 from %ir.addr)
338    $s0 = COPY %1(s32)
339...
340
341---
342name:            load_s16_fpr
343legalized:       true
344regBankSelected: true
345
346registers:
347  - { id: 0, class: gpr }
348  - { id: 1, class: fpr }
349
350body:             |
351  bb.0:
352    liveins: $x0
353
354    ; CHECK-LABEL: name: load_s16_fpr
355    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
356    ; CHECK: [[LDRHui:%[0-9]+]]:fpr16 = LDRHui [[COPY]], 0 :: (load 2 from %ir.addr)
357    ; CHECK: $h0 = COPY [[LDRHui]]
358    %0(p0) = COPY $x0
359    %1(s16) = G_LOAD  %0 :: (load 2 from %ir.addr)
360    $h0 = COPY %1(s16)
361...
362
363---
364name:            load_s8_fpr
365legalized:       true
366regBankSelected: true
367
368registers:
369  - { id: 0, class: gpr }
370  - { id: 1, class: fpr }
371
372body:             |
373  bb.0:
374    liveins: $x0
375
376    ; CHECK-LABEL: name: load_s8_fpr
377    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
378    ; CHECK: [[LDRBui:%[0-9]+]]:fpr8 = LDRBui [[COPY]], 0 :: (load 1 from %ir.addr)
379    ; CHECK: $b0 = COPY [[LDRBui]]
380    %0(p0) = COPY $x0
381    %1(s8) = G_LOAD  %0 :: (load 1 from %ir.addr)
382    $b0 = COPY %1(s8)
383...
384
385---
386name:            load_gep_8_s64_fpr
387legalized:       true
388regBankSelected: true
389
390registers:
391  - { id: 0, class: gpr }
392  - { id: 1, class: gpr }
393  - { id: 2, class: gpr }
394  - { id: 3, class: fpr }
395
396body:             |
397  bb.0:
398    liveins: $x0
399
400    ; CHECK-LABEL: name: load_gep_8_s64_fpr
401    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
402    ; CHECK: [[LDRDui:%[0-9]+]]:fpr64 = LDRDui [[COPY]], 1 :: (load 8 from %ir.addr)
403    ; CHECK: $d0 = COPY [[LDRDui]]
404    %0(p0) = COPY $x0
405    %1(s64) = G_CONSTANT i64 8
406    %2(p0) = G_GEP %0, %1
407    %3(s64) = G_LOAD %2 :: (load 8 from %ir.addr)
408    $d0 = COPY %3
409...
410
411---
412name:            load_gep_16_s32_fpr
413legalized:       true
414regBankSelected: true
415
416registers:
417  - { id: 0, class: gpr }
418  - { id: 1, class: gpr }
419  - { id: 2, class: gpr }
420  - { id: 3, class: fpr }
421
422body:             |
423  bb.0:
424    liveins: $x0
425
426    ; CHECK-LABEL: name: load_gep_16_s32_fpr
427    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
428    ; CHECK: [[LDRSui:%[0-9]+]]:fpr32 = LDRSui [[COPY]], 4 :: (load 4 from %ir.addr)
429    ; CHECK: $s0 = COPY [[LDRSui]]
430    %0(p0) = COPY $x0
431    %1(s64) = G_CONSTANT i64 16
432    %2(p0) = G_GEP %0, %1
433    %3(s32) = G_LOAD %2 :: (load 4 from %ir.addr)
434    $s0 = COPY %3
435...
436
437---
438name:            load_gep_64_s16_fpr
439legalized:       true
440regBankSelected: true
441
442registers:
443  - { id: 0, class: gpr }
444  - { id: 1, class: gpr }
445  - { id: 2, class: gpr }
446  - { id: 3, class: fpr }
447
448body:             |
449  bb.0:
450    liveins: $x0
451
452    ; CHECK-LABEL: name: load_gep_64_s16_fpr
453    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
454    ; CHECK: [[LDRHui:%[0-9]+]]:fpr16 = LDRHui [[COPY]], 32 :: (load 2 from %ir.addr)
455    ; CHECK: $h0 = COPY [[LDRHui]]
456    %0(p0) = COPY $x0
457    %1(s64) = G_CONSTANT i64 64
458    %2(p0) = G_GEP %0, %1
459    %3(s16) = G_LOAD %2 :: (load 2 from %ir.addr)
460    $h0 = COPY %3
461...
462
463---
464name:            load_gep_32_s8_fpr
465legalized:       true
466regBankSelected: true
467
468registers:
469  - { id: 0, class: gpr }
470  - { id: 1, class: gpr }
471  - { id: 2, class: gpr }
472  - { id: 3, class: fpr }
473
474body:             |
475  bb.0:
476    liveins: $x0
477
478    ; CHECK-LABEL: name: load_gep_32_s8_fpr
479    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
480    ; CHECK: [[LDRBui:%[0-9]+]]:fpr8 = LDRBui [[COPY]], 32 :: (load 1 from %ir.addr)
481    ; CHECK: $b0 = COPY [[LDRBui]]
482    %0(p0) = COPY $x0
483    %1(s64) = G_CONSTANT i64 32
484    %2(p0) = G_GEP %0, %1
485    %3(s8) = G_LOAD %2 :: (load 1 from %ir.addr)
486    $b0 = COPY %3
487...
488---
489name:            load_v2s32
490legalized:       true
491regBankSelected: true
492
493registers:
494  - { id: 0, class: gpr }
495  - { id: 1, class: fpr }
496
497body:             |
498  bb.0:
499    liveins: $x0
500
501    ; CHECK-LABEL: name: load_v2s32
502    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
503    ; CHECK: [[LDRDui:%[0-9]+]]:fpr64 = LDRDui [[COPY]], 0 :: (load 8 from %ir.addr)
504    ; CHECK: $d0 = COPY [[LDRDui]]
505    %0(p0) = COPY $x0
506    %1(<2 x s32>) = G_LOAD %0 :: (load 8 from %ir.addr)
507    $d0 = COPY %1(<2 x s32>)
508...
509