Compiler projects using llvm
# RUN: llc -simplify-mir -march=amdgcn -mcpu=gfx900 -run-pass=si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s

# GCN-LABEL: name: swap_phys_condensed
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
# GCN-NEXT: S_SETPC_B64_return
---
name:            swap_phys_condensed
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_phys_sparse
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
# GCN-NEXT: S_SETPC_B64_return
---
name:            swap_phys_sparse
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr4, $vgpr6, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_phys_liveout
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
# GCN-NEXT: S_SETPC_B64_return
---
name:            swap_phys_liveout
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_phys_liveout_superreg
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
# GCN-NEXT: S_SETPC_B64_return
---
name:            swap_phys_liveout_superreg
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_phys_b64
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr4_vgpr5 = COPY $vgpr0_vgpr1
# GCN-NEXT: $vgpr0, $vgpr2 = V_SWAP_B32 $vgpr2, $vgpr0, implicit $exec
# GCN-NEXT: $vgpr1, $vgpr3 = V_SWAP_B32 $vgpr3, $vgpr1, implicit $exec
---
name:            swap_phys_b64
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
    $vgpr4_vgpr5 = COPY killed $vgpr0_vgpr1
    $vgpr0_vgpr1 = COPY killed $vgpr2_vgpr3
    $vgpr2_vgpr3 = COPY killed $vgpr4_vgpr5
...

# GCN-LABEL: name: swap_phys_overlap_x
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr3_vgpr4 = V_ADD_F64_e64 0, $vgpr0_vgpr1, 0, $vgpr3_vgpr4, 0, 0, implicit $mode, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
---
name:            swap_phys_overlap_x
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1, $vgpr3_vgpr4
    $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
    $vgpr3_vgpr4 = V_ADD_F64_e64 0, $vgpr0_vgpr1, 0, $vgpr3_vgpr4, 0, 0, implicit $mode, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
...

# GCN-LABEL: name: swap_phys_clobber_y
# GCN: bb.0:
# GCN-NEXT: liveins:
# GCN-NEXT: {{^[ ]*$}}
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 0, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
---
name:            swap_phys_clobber_y
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1
    $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 0, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_copy_condense
# GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
---
name:            swap_virt_copy_condense
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_copy_sparse
# GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
---
name:            swap_virt_copy_sparse
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    S_NOP 0
    %0 = COPY %1
    S_NOP 0
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_copy_subreg
# GCN: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
---
name:            swap_virt_copy_subreg
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0
    %2.sub1 = COPY %0.sub1
    %0.sub0 = COPY %1.sub0
    %0.sub1 = COPY %1.sub1
    %1.sub0 = COPY %2.sub0
...

# GCN-LABEL: name: swap_virt_mov
# GCN: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
---
name:            swap_virt_mov
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = V_MOV_B32_e32 %0, implicit $exec
    %0 = V_MOV_B32_e32 %1, implicit $exec
    %1 = V_MOV_B32_e32 %2, implicit $exec
...

# GCN-LABEL: name: swap_virt_read_x
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %3:vgpr_32 = COPY %0
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_read_x
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
  - { id: 3, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %3 = COPY %0
    %0 = COPY %1
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_read_t_twice
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %3:vgpr_32 = COPY %2
# GCN-NEXT: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_read_t_twice
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
  - { id: 3, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %3 = COPY %2
    %0 = COPY %1
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_clobber_y
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_clobber_y
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %1 = IMPLICIT_DEF
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_clobber_x1
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_clobber_x1
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %0 = IMPLICIT_DEF
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_clobber_x2
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_clobber_x2
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = IMPLICIT_DEF
    %0 = COPY %1
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_clobber_t
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %2:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_virt_clobber_t
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %2 = IMPLICIT_DEF
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_copy_subreg_overlap_x_full
# GCN: bb.0:
# GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
# GCN-NEXT: %3:vreg_64 = COPY %0
# GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0
# GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
---
name:            swap_virt_copy_subreg_overlap_x_full
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
  - { id: 3, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0
    %3 = COPY %0
    %0.sub0 = COPY %1.sub0
    %1.sub0 = COPY %2.sub0
...

# GCN-LABEL: name: swap_virt_copy_subreg_overlap_x_part
# GCN: bb.0:
# GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
# GCN-NEXT: %3:vreg_64 = COPY %0.sub0_sub1
# GCN-NEXT: %0.sub0:vreg_128 = COPY %1.sub0
# GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
---
name:            swap_virt_copy_subreg_overlap_x_part
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_128 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
  - { id: 3, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0
    %3 = COPY %0.sub0_sub1
    %0.sub0 = COPY %1.sub0
    %1.sub0 = COPY %2.sub0
...

# GCN-LABEL: name: swap_virt_copy_subreg_wide_y
# GCN: bb.0:
# GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
# GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0
# GCN-NEXT: %1:vreg_64 = COPY %2
---
name:            swap_virt_copy_subreg_wide_y
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0
    %0.sub0 = COPY %1.sub0
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_b64
# GCN: bb.0:
# GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
# GCN-NEXT: %0.sub1:vreg_64, %1.sub1:vreg_64 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
---
name:            swap_virt_b64
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_b128
# GCN: bb.0:
# GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %0.sub0:vreg_128, %1.sub0:vreg_128 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
# GCN-NEXT: %0.sub1:vreg_128, %1.sub1:vreg_128 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
# GCN-NEXT: %0.sub2:vreg_128, %1.sub2:vreg_128 = V_SWAP_B32 %1.sub2, %0.sub2, implicit $exec
# GCN-NEXT: %0.sub3:vreg_128, %1.sub3:vreg_128 = V_SWAP_B32 %1.sub3, %0.sub3, implicit $exec
---
name:            swap_virt_b128
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_128 }
  - { id: 1, class: vreg_128 }
  - { id: 2, class: vreg_128 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_b128_sub0_1
# GCN: bb.0:
# GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %0.sub0:vreg_128, %1.sub0:vreg_128 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
# GCN-NEXT: %0.sub1:vreg_128, %1.sub1:vreg_128 = V_SWAP_B32 %1.sub1, %0.sub1, implicit $exec
# GCN-NEXT: S_ENDPGM 0
---
name:            swap_virt_b128_sub0_1
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_128 }
  - { id: 1, class: vreg_128 }
  - { id: 2, class: vreg_128 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0_sub1 = COPY %0.sub0_sub1
    %0.sub0_sub1 = COPY %1.sub0_sub1
    %1.sub0_sub1 = COPY %2.sub0_sub1
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_virt_b128_sub2_3
# GCN: bb.0:
# GCN-NEXT: %0:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_128 = IMPLICIT_DEF
# GCN-NEXT: %0.sub2:vreg_128, %1.sub2:vreg_128 = V_SWAP_B32 %1.sub2, %0.sub2, implicit $exec
# GCN-NEXT: %0.sub3:vreg_128, %1.sub3:vreg_128 = V_SWAP_B32 %1.sub3, %0.sub3, implicit $exec
# GCN-NEXT: S_ENDPGM 0
---
name:            swap_virt_b128_sub2_3
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_128 }
  - { id: 1, class: vreg_128 }
  - { id: 2, class: vreg_128 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub2_sub3 = COPY %0.sub2_sub3
    %0.sub2_sub3 = COPY %1.sub2_sub3
    %1.sub2_sub3 = COPY %2.sub2_sub3
    S_ENDPGM 0
...


# GCN-LABEL: name: swap_virt_s_to_s
# GCN: bb.0:
# GCN-NEXT: %0:sgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:sgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:sgpr_32 = COPY %0
# GCN-NEXT: %0:sgpr_32 = COPY %1
# GCN-NEXT: %1:sgpr_32 = COPY %2
---
name:            swap_virt_s_to_s
tracksRegLiveness: true
registers:
  - { id: 0, class: sgpr_32 }
  - { id: 1, class: sgpr_32 }
  - { id: 2, class: sgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %0 = COPY %1
    %1 = COPY %2
...

# GCN-LABEL: name: swap_virt_copy_subreg_impdef_super
# GCN:      %2:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %2.sub1:vreg_64 = COPY %0.sub1
# GCN-NEXT: %0.sub0:vreg_64, %1.sub0:vreg_64 = V_SWAP_B32 %1.sub0, %0.sub0, implicit $exec
---
name:            swap_virt_copy_subreg_impdef_super
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0, implicit-def %2, implicit $exec
    %2.sub1 = COPY %0.sub1
    %0.sub0 = COPY %1.sub0
    %0.sub1 = COPY %1.sub1
    %1.sub0 = COPY %2.sub0
...

# GCN-LABEL: name: swap_virt_copy_subreg_impuse_x
# GCN: bb.0:
# GCN-NEXT: %0:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %1:vreg_64 = IMPLICIT_DEF
# GCN-NEXT: %2.sub0:vreg_64 = COPY %0.sub0
# GCN-NEXT: %2.sub1:vreg_64 = COPY %0.sub1
# GCN-NEXT: %0.sub0:vreg_64 = COPY %1.sub0, implicit %0
# GCN-NEXT: %0.sub1:vreg_64 = COPY %1.sub1
# GCN-NEXT: %1.sub0:vreg_64 = COPY %2.sub0
# GCN-NEXT: S_ENDPGM 0
---
name:            swap_virt_copy_subreg_impuse_x
tracksRegLiveness: true
registers:
  - { id: 0, class: vreg_64 }
  - { id: 1, class: vreg_64 }
  - { id: 2, class: vreg_64 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2.sub0 = COPY %0.sub0
    %2.sub1 = COPY %0.sub1
    %0.sub0 = COPY %1.sub0, implicit %0
    %0.sub1 = COPY %1.sub1
    %1.sub0 = COPY %2.sub0
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_exact_max_insns_apart
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %3:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %0:vgpr_32, %1:vgpr_32 = V_SWAP_B32 %1, %0, implicit $exec
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_exact_max_insns_apart
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
  - { id: 3, class: vgpr_32 }
  - { id: 4, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %3 = IMPLICIT_DEF
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %0 = COPY %1
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_too_far
# GCN: bb.0:
# GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %1:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %2:vgpr_32 = COPY %0
# GCN-NEXT: %3:vgpr_32 = IMPLICIT_DEF
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %4:vgpr_32 = COPY %3
# GCN-NEXT: %3:vgpr_32 = COPY %4
# GCN-NEXT: %0:vgpr_32 = COPY %1
# GCN-NEXT: %1:vgpr_32 = COPY %2
# GCN-NEXT: S_ENDPGM 0

---
name:            swap_too_far
tracksRegLiveness: true
registers:
  - { id: 0, class: vgpr_32 }
  - { id: 1, class: vgpr_32 }
  - { id: 2, class: vgpr_32 }
  - { id: 3, class: vgpr_32 }
  - { id: 4, class: vgpr_32 }
body:             |
  bb.0:
    %0 = IMPLICIT_DEF
    %1 = IMPLICIT_DEF
    %2 = COPY %0
    %3 = IMPLICIT_DEF
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %4 = COPY %3
    %3 = COPY %4
    %0 = COPY %1
    %1 = COPY %2
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_liveness_error_mov
# GCN:      $vgpr6 = V_MOV_B32_e32 $vgpr1, implicit $exec
# GCN-NEXT: $vgpr1, $vgpr5 = V_SWAP_B32 $vgpr5, $vgpr1, implicit $exec
# GCN-NEXT: $vgpr5_vgpr6 = IMPLICIT_DEF
# GCN-NEXT: $vgpr6 = V_MOV_B32_e32 $vgpr7, implicit $exec, implicit $vgpr6_vgpr7
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 $vgpr6, implicit $exec

---
name: swap_liveness_error_mov
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr5, $vgpr1_vgpr2

    $vgpr6 = V_MOV_B32_e32 $vgpr1, implicit $exec, implicit killed $vgpr1_vgpr2
    $vgpr1 = V_MOV_B32_e32 killed $vgpr5, implicit $exec
    $vgpr5 = V_MOV_B32_e32 $vgpr6, implicit $exec, implicit-def $vgpr5_vgpr6, implicit $vgpr6_vgpr7
    $vgpr6 = V_MOV_B32_e32 $vgpr7, implicit $exec, implicit $vgpr6_vgpr7
    $vgpr5 = V_MOV_B32_e32 $vgpr6, implicit $exec
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_liveness_error_copy
# GCN:      $vgpr6 = COPY $vgpr1
# GCN-NEXT: $vgpr1, $vgpr5 = V_SWAP_B32 $vgpr5, $vgpr1, implicit $exec
# GCN-NEXT: $vgpr5_vgpr6 = IMPLICIT_DEF
# GCN-NEXT: $vgpr6 = COPY $vgpr7, implicit $vgpr6_vgpr7
# GCN-NEXT: $vgpr5 = COPY $vgpr6

---
name: swap_liveness_error_copy
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr5, $vgpr1_vgpr2

    $vgpr6 = COPY $vgpr1, implicit killed $vgpr1_vgpr2
    $vgpr1 = COPY killed $vgpr5
    $vgpr5 = COPY $vgpr6, implicit-def $vgpr5_vgpr6, implicit $vgpr6_vgpr7
    $vgpr6 = COPY $vgpr7, implicit $vgpr6_vgpr7
    $vgpr5 = COPY $vgpr6
    S_ENDPGM 0
...

# GCN-LABEL: name: swap_killed_t_early
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
# GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec, implicit killed $vgpr2
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 undef $vgpr2, implicit $exec

---
name:            swap_killed_t_early
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr4, $vgpr6, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec, implicit killed $vgpr2
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
    $vgpr1 = V_MOV_B32_e32 undef $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_killed_t_late
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
# GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec, implicit killed $vgpr2
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 undef $vgpr2, implicit $exec

---
name:            swap_killed_t_late
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr4, $vgpr6, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec, implicit killed $vgpr2
    $vgpr1 = V_MOV_B32_e32 undef $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: swap_killed_x
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
# GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec, implicit killed $vgpr0
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec

---
name:            swap_killed_x
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr4, $vgpr6, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec, implicit killed $vgpr0
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr1
...

# GCN-LABEL: name: indirect_mov_t
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec, implicit $m0
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
# GCN-NEXT: S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1

---
name:            indirect_mov_t
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec, implicit $m0
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: indirect_mov_x
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec, implicit $m0
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
# GCN-NEXT: S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1

---
name:            indirect_mov_x
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec, implicit $m0
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: indirect_mov_y
# GCN:      $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
# GCN-NEXT: $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec, implicit $m0
# GCN-NEXT: S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1

---
name:            indirect_mov_y
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr2 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr2, implicit $exec, implicit $m0
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: implicit_ops_mov_x_swap_b32
# GCN: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec, implicit $vgpr2, implicit killed $vgpr1_vgpr2

---
name:            implicit_ops_mov_x_swap_b32
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr3 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec, implicit $vgpr2, implicit killed $vgpr1_vgpr2
    $vgpr1 = V_MOV_B32_e32 killed $vgpr3, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: name: implict_ops_mov_x_swap_b64
# GCN:      %2:vreg_64 = COPY %0
# GCN-NEXT: %0:vreg_64 = COPY %1, implicit $vgpr0
# GCN-NEXT: %1:vreg_64 = COPY %2

---
name:            implict_ops_mov_x_swap_b64
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0
    %0:vreg_64 = IMPLICIT_DEF
    %1:vreg_64 = IMPLICIT_DEF
    %2:vreg_64 = COPY %0
    %0:vreg_64 = COPY %1, implicit $vgpr0
    %1:vreg_64 = COPY %2
...

# GCN-LABEL: implicit_ops_mov_t_swap_b32
# GCN:      $vgpr3 = V_MOV_B32_e32 $vgpr0, implicit $exec, implicit $vgpr2, implicit killed $vgpr1_vgpr2, implicit-def $vgpr1
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec

---
name:            implicit_ops_mov_t_swap_b32
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
    $vgpr3 = V_MOV_B32_e32 killed $vgpr0, implicit $exec, implicit $vgpr2, implicit killed $vgpr1_vgpr2, implicit-def $vgpr1
    $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr3, implicit $exec
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...

# GCN-LABEL: implicit_ops_mov_y_swap_b32
# GCN:      $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
# GCN-NEXT: $vgpr0_vgpr1 = IMPLICIT_DEF

---
name:            implicit_ops_mov_y_swap_b32
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr30_sgpr31
    $vgpr3 = V_MOV_B32_e32 killed $vgpr0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec
    $vgpr1 = V_MOV_B32_e32 killed $vgpr3, implicit $exec, implicit $vgpr2, implicit-def $vgpr0_vgpr1, implicit killed $vgpr3
    S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit $vgpr1
...