1 # RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
3 # GCN-LABEL: name: swap_phys_condensed
5 # GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
6 # GCN-NEXT: S_SETPC_B64_return
8 name: swap_phys_condensed
11 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
12 $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
13 $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
14 $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
15 S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
18 # GCN-LABEL: name: swap_phys_sparse
20 # GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
21 # GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
22 # GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
23 # GCN-NEXT: S_SETPC_B64_return
25 name: swap_phys_sparse
28 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
29 $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
30 $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
31 $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
32 $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
33 $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
34 S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
37 # GCN-LABEL: name: swap_phys_liveout
39 # GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
40 # GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
41 # GCN-NEXT: S_SETPC_B64_return
43 name: swap_phys_liveout
46 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
47 $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
48 $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
49 $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
50 S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr2, implicit $vgpr1
53 # GCN-LABEL: name: swap_phys_b64
55 # GCN-NEXT: $vgpr0, $vgpr2 = V_SWAP_B32 $vgpr2, $vgpr0, implicit $exec
56 # GCN-NEXT: $vgpr1, $vgpr3 = V_SWAP_B32 $vgpr3, $vgpr1, implicit $exec
61 $vgpr4_vgpr5 = COPY killed $vgpr0_vgpr1
62 $vgpr0_vgpr1 = COPY killed $vgpr2_vgpr3
63 $vgpr2_vgpr3 = COPY killed $vgpr4_vgpr5
66 # GCN-LABEL: name: swap_phys_overlap_x
68 # GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
69 # GCN-NEXT: $vgpr3_vgpr4 = V_ADD_F64 0, $vgpr0_vgpr1, 0, $vgpr3_vgpr4, 0, 0, implicit $exec
70 # GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
71 # GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
73 name: swap_phys_overlap_x
76 $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
77 $vgpr3_vgpr4 = V_ADD_F64 0, $vgpr0_vgpr1, 0, $vgpr3_vgpr4, 0, 0, implicit $exec
78 $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
79 $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
82 # GCN-LABEL: name: swap_phys_clobber_y
84 # GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
85 # GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
86 # GCN-NEXT: $vgpr1 = V_MOV_B32_e32 0, implicit $exec
87 # GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
89 name: swap_phys_clobber_y
92 $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
93 $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
94 $vgpr1 = V_MOV_B32_e32 0, implicit $exec
95 $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
99 # GCN-LABEL: name: swap_virt_copy_condense
100 # GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
102 name: swap_virt_copy_condense
104 - { id: 0, class: vgpr_32 }
105 - { id: 1, class: vgpr_32 }
106 - { id: 2, class: vgpr_32 }
116 # GCN-LABEL: name: swap_virt_copy_sparse
117 # GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
119 name: swap_virt_copy_sparse
121 - { id: 0, class: vgpr_32 }
122 - { id: 1, class: vgpr_32 }
123 - { id: 2, class: vgpr_32 }
135 # GCN-LABEL: name: swap_virt_copy_subreg
136 # GCN: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
138 name: swap_virt_copy_subreg
140 - { id: 0, class: vreg_64 }
141 - { id: 1, class: vreg_64 }
142 - { id: 2, class: vreg_64 }
147 %2.sub0 = COPY %0.sub0
148 %2.sub1 = COPY %0.sub1
149 %0.sub0 = COPY %1.sub0
150 %0.sub1 = COPY %1.sub1
151 %1.sub0 = COPY %2.sub0
154 # GCN-LABEL: name: swap_virt_mov
155 # GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
159 - { id: 0, class: vgpr_32 }
160 - { id: 1, class: vgpr_32 }
161 - { id: 2, class: vgpr_32 }
166 %2 = V_MOV_B32_e32 %0, implicit $exec
167 %0 = V_MOV_B32_e32 %1, implicit $exec
168 %1 = V_MOV_B32_e32 %2, implicit $exec
171 # GCN-LABEL: name: swap_virt_read_x
173 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
174 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
175 # GCN-NEXT: %2:vgpr_32 = COPY %0
176 # GCN-NEXT: %3:vgpr_32 = COPY %0
177 # GCN-NEXT: %0:vgpr_32 = COPY %1
178 # GCN-NEXT: %1:vgpr_32 = COPY %2
179 # GCN-NEXT: S_ENDPGM 0
182 name: swap_virt_read_x
184 - { id: 0, class: vgpr_32 }
185 - { id: 1, class: vgpr_32 }
186 - { id: 2, class: vgpr_32 }
187 - { id: 3, class: vgpr_32 }
199 # GCN-LABEL: name: swap_virt_read_t_twice
201 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
202 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
203 # GCN-NEXT: %2:vgpr_32 = COPY %0
204 # GCN-NEXT: %3:vgpr_32 = COPY %2
205 # GCN-NEXT: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
206 # GCN-NEXT: S_ENDPGM 0
209 name: swap_virt_read_t_twice
211 - { id: 0, class: vgpr_32 }
212 - { id: 1, class: vgpr_32 }
213 - { id: 2, class: vgpr_32 }
214 - { id: 3, class: vgpr_32 }
226 # GCN-LABEL: name: swap_virt_clobber_y
228 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
229 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
230 # GCN-NEXT: %2:vgpr_32 = COPY %0
231 # GCN-NEXT: %0:vgpr_32 = COPY %1
232 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
233 # GCN-NEXT: %1:vgpr_32 = COPY %2
234 # GCN-NEXT: S_ENDPGM 0
237 name: swap_virt_clobber_y
239 - { id: 0, class: vgpr_32 }
240 - { id: 1, class: vgpr_32 }
241 - { id: 2, class: vgpr_32 }
253 # GCN-LABEL: name: swap_virt_clobber_x1
255 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
256 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
257 # GCN-NEXT: %2:vgpr_32 = COPY %0
258 # GCN-NEXT: %0:vgpr_32 = COPY %1
259 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
260 # GCN-NEXT: %1:vgpr_32 = COPY %2
261 # GCN-NEXT: S_ENDPGM 0
264 name: swap_virt_clobber_x1
266 - { id: 0, class: vgpr_32 }
267 - { id: 1, class: vgpr_32 }
268 - { id: 2, class: vgpr_32 }
280 # GCN-LABEL: name: swap_virt_clobber_x2
282 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
283 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
284 # GCN-NEXT: %2:vgpr_32 = COPY %0
285 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
286 # GCN-NEXT: %0:vgpr_32 = COPY %1
287 # GCN-NEXT: %1:vgpr_32 = COPY %2
288 # GCN-NEXT: S_ENDPGM 0
291 name: swap_virt_clobber_x2
293 - { id: 0, class: vgpr_32 }
294 - { id: 1, class: vgpr_32 }
295 - { id: 2, class: vgpr_32 }
307 # GCN-LABEL: name: swap_virt_clobber_t
309 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
310 # GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
311 # GCN-NEXT: %2:vgpr_32 = COPY %0
312 # GCN-NEXT: %0:vgpr_32 = COPY %1
313 # GCN-NEXT: %2:vgpr_32 = IMPLICIT_DEF
314 # GCN-NEXT: %1:vgpr_32 = COPY %2
315 # GCN-NEXT: S_ENDPGM 0
318 name: swap_virt_clobber_t
320 - { id: 0, class: vgpr_32 }
321 - { id: 1, class: vgpr_32 }
322 - { id: 2, class: vgpr_32 }
334 # GCN-LABEL: name: swap_virt_copy_subreg_overlap_x_full
336 # GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
337 # GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
338 # GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
339 # GCN-NEXT: %3:vreg_64 = COPY %0
340 # GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0
341 # GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
343 name: swap_virt_copy_subreg_overlap_x_full
345 - { id: 0, class: vreg_64 }
346 - { id: 1, class: vreg_64 }
347 - { id: 2, class: vreg_64 }
348 - { id: 3, class: vreg_64 }
353 %2.sub0 = COPY %0.sub0
355 %0.sub0 = COPY %1.sub0
356 %1.sub0 = COPY %2.sub0
359 # GCN-LABEL: name: swap_virt_copy_subreg_overlap_x_part
361 # GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
362 # GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
363 # GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
364 # GCN-NEXT: %3:vreg_64 = COPY %0.sub0_sub1
365 # GCN-NEXT: %0.sub0:vreg_128 = COPY %1.sub0
366 # GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
368 name: swap_virt_copy_subreg_overlap_x_part
370 - { id: 0, class: vreg_128 }
371 - { id: 1, class: vreg_64 }
372 - { id: 2, class: vreg_64 }
373 - { id: 3, class: vreg_64 }
378 %2.sub0 = COPY %0.sub0
379 %3 = COPY %0.sub0_sub1
380 %0.sub0 = COPY %1.sub0
381 %1.sub0 = COPY %2.sub0
384 # GCN-LABEL: name: swap_virt_copy_subreg_wide_y
386 # GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
387 # GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
388 # GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
389 # GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0
390 # GCN-NEXT: %1:vreg_64 = COPY %2
392 name: swap_virt_copy_subreg_wide_y
394 - { id: 0, class: vreg_64 }
395 - { id: 1, class: vreg_64 }
396 - { id: 2, class: vreg_64 }
401 %2.sub0 = COPY %0.sub0
402 %0.sub0 = COPY %1.sub0
406 # GCN-LABEL: name: swap_virt_b64
408 # GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
409 # GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
410 # GCN-NEXT: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
411 # GCN-NEXT: %0.sub1:vreg_64, %1.sub1:vreg_64 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
415 - { id: 0, class: vreg_64 }
416 - { id: 1, class: vreg_64 }
417 - { id: 2, class: vreg_64 }
427 # GCN-LABEL: name: swap_virt_b128
429 # GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
430 # GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
431 # GCN-NEXT: %0.sub0:vreg_128, %1.sub0:vreg_128 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
432 # GCN-NEXT: %0.sub1:vreg_128, %1.sub1:vreg_128 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
433 # GCN-NEXT: %0.sub2:vreg_128, %1.sub2:vreg_128 = V_SWAP_B32 %1.sub2, %0.sub2, implicit $exec
434 # GCN-NEXT: %0.sub3:vreg_128, %1.sub3:vreg_128 = V_SWAP_B32 %1.sub3, %0.sub3, implicit $exec
438 - { id: 0, class: vreg_128 }
439 - { id: 1, class: vreg_128 }
440 - { id: 2, class: vreg_128 }
450 # GCN-LABEL: name: swap_virt_b128_sub0_1
452 # GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
453 # GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
454 # GCN-NEXT: %0.sub0:vreg_128, %1.sub0:vreg_128 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
455 # GCN-NEXT: %0.sub1:vreg_128, %1.sub1:vreg_128 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
456 # GCN-NEXT: S_ENDPGM 0
458 name: swap_virt_b128_sub0_1
460 - { id: 0, class: vreg_128 }
461 - { id: 1, class: vreg_128 }
462 - { id: 2, class: vreg_128 }
467 %2.sub0_sub1 = COPY %0.sub0_sub1
468 %0.sub0_sub1 = COPY %1.sub0_sub1
469 %1.sub0_sub1 = COPY %2.sub0_sub1
473 # GCN-LABEL: name: swap_virt_b128_sub2_3
475 # GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
476 # GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
477 # GCN-NEXT: %0.sub2:vreg_128, %1.sub2:vreg_128 = V_SWAP_B32 %1.sub2, %0.sub2, implicit $exec
478 # GCN-NEXT: %0.sub3:vreg_128, %1.sub3:vreg_128 = V_SWAP_B32 %1.sub3, %0.sub3, implicit $exec
479 # GCN-NEXT: S_ENDPGM 0
481 name: swap_virt_b128_sub2_3
483 - { id: 0, class: vreg_128 }
484 - { id: 1, class: vreg_128 }
485 - { id: 2, class: vreg_128 }
490 %2.sub2_sub3 = COPY %0.sub2_sub3
491 %0.sub2_sub3 = COPY %1.sub2_sub3
492 %1.sub2_sub3 = COPY %2.sub2_sub3
497 # GCN-LABEL: name: swap_virt_s_to_s
499 # GCN-NEXT: %0:sgpr_32 = IMPLICIT_DEF
500 # GCN-NEXT: %1:sgpr_32 = IMPLICIT_DEF
501 # GCN-NEXT: %2:sgpr_32 = COPY %0
502 # GCN-NEXT: %0:sgpr_32 = COPY %1
503 # GCN-NEXT: %1:sgpr_32 = COPY %2
505 name: swap_virt_s_to_s
507 - { id: 0, class: sgpr_32 }
508 - { id: 1, class: sgpr_32 }
509 - { id: 2, class: sgpr_32 }
519 # GCN-LABEL: name: swap_virt_copy_subreg_impdef_super
520 # GCN: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
522 name: swap_virt_copy_subreg_impdef_super
524 - { id: 0, class: vreg_64 }
525 - { id: 1, class: vreg_64 }
526 - { id: 2, class: vreg_64 }
531 %2.sub0 = COPY %0.sub0, implicit-def %2, implicit $exec
532 %2.sub1 = COPY %0.sub1
533 %0.sub0 = COPY %1.sub0
534 %0.sub1 = COPY %1.sub1
535 %1.sub0 = COPY %2.sub0
538 # GCN-LABEL: name: swap_virt_copy_subreg_impuse_x
540 # GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
541 # GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
542 # GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
543 # GCN-NEXT: %2.sub1:vreg_64 = COPY %0.sub1
544 # GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0, implicit %0
545 # GCN-NEXT: %0.sub1:vreg_64 = COPY %1.sub1
546 # GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
547 # GCN-NEXT: S_ENDPGM 0
549 name: swap_virt_copy_subreg_impuse_x
551 - { id: 0, class: vreg_64 }
552 - { id: 1, class: vreg_64 }
553 - { id: 2, class: vreg_64 }
558 %2.sub0 = COPY %0.sub0
559 %2.sub1 = COPY %0.sub1
560 %0.sub0 = COPY %1.sub0, implicit %0
561 %0.sub1 = COPY %1.sub1
562 %1.sub0 = COPY %2.sub0