# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -simplify-mir -start-before=greedy,2 -stress-regalloc=3 -stop-after=postrapseudos -o - -verify-regalloc %s | FileCheck %s

# Compare results of using V_MOV_B32 vs. AV_MOV_B32_IMM_PSEUDO during
# allocation.

---
name: av_mov_b32_split
tracksRegLiveness: true
machineFunctionInfo:
  isEntryFunction: true
  scratchRSrcReg:  '$sgpr72_sgpr73_sgpr74_sgpr75'
  stackPtrOffsetReg: '$sgpr32'
  occupancy:       7
body:             |
  bb.0:
    liveins: $vgpr0, $sgpr4_sgpr5

    ; CHECK-LABEL: name: av_mov_b32_split
    ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr4_sgpr5
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: renamable $agpr0 = V_ACCVGPR_WRITE_B32_e64 0, implicit $exec
    ; CHECK-NEXT: renamable $agpr1 = V_ACCVGPR_WRITE_B32_e64 1, implicit $exec
    ; CHECK-NEXT: renamable $agpr2 = V_ACCVGPR_WRITE_B32_e64 2, implicit $exec
    ; CHECK-NEXT: $vgpr0 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: renamable $agpr0 = V_ACCVGPR_WRITE_B32_e64 3, implicit $exec
    ; CHECK-NEXT: $vgpr1 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: renamable $agpr0 = V_ACCVGPR_WRITE_B32_e64 4, implicit $exec
    ; CHECK-NEXT: $vgpr2 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr0, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr1
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr2
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr1, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr2, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    %0:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 0, implicit $exec
    %1:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 1, implicit $exec
    %2:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 2, implicit $exec
    %3:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 3, implicit $exec
    %4:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 4, implicit $exec

    %5:agpr_32 = COPY %0
    %6:agpr_32 = COPY %1
    %7:agpr_32 = COPY %2
    %8:agpr_32 = COPY %3
    %9:agpr_32 = COPY %4

    S_NOP 0, implicit %5
    S_NOP 0, implicit %6
    S_NOP 0, implicit %7
    S_NOP 0, implicit %8
    S_NOP 0, implicit %9

...

---
name: v_mov_b32_split
tracksRegLiveness: true
machineFunctionInfo:
  isEntryFunction: true
  scratchRSrcReg:  '$sgpr72_sgpr73_sgpr74_sgpr75'
  stackPtrOffsetReg: '$sgpr32'
  occupancy:       7
body:             |
  bb.0:
    liveins: $vgpr0, $sgpr4_sgpr5

    ; CHECK-LABEL: name: v_mov_b32_split
    ; CHECK: liveins: $vgpr0, $vgpr3, $vgpr4, $vgpr5, $sgpr4_sgpr5
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
    ; CHECK-NEXT: renamable $vgpr1 = V_MOV_B32_e32 1, implicit $exec
    ; CHECK-NEXT: renamable $vgpr2 = V_MOV_B32_e32 2, implicit $exec
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 killed $vgpr0, implicit $exec, implicit $exec
    ; CHECK-NEXT: $vgpr3 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: $agpr1 = V_ACCVGPR_WRITE_B32_e64 killed $vgpr1, implicit $exec, implicit $exec
    ; CHECK-NEXT: $agpr2 = V_ACCVGPR_WRITE_B32_e64 killed $vgpr2, implicit $exec, implicit $exec
    ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 3, implicit $exec
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 killed $vgpr0, implicit $exec, implicit $exec
    ; CHECK-NEXT: $vgpr4 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 4, implicit $exec
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 killed $vgpr0, implicit $exec, implicit $exec
    ; CHECK-NEXT: $vgpr5 = V_ACCVGPR_READ_B32_e64 killed $agpr0, implicit $exec
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr3, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr1
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr2
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr4, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    ; CHECK-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 $vgpr5, implicit $exec
    ; CHECK-NEXT: S_NOP 0, implicit killed renamable $agpr0
    %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
    %1:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
    %2:vgpr_32 = V_MOV_B32_e32 2, implicit $exec
    %3:vgpr_32 = V_MOV_B32_e32 3, implicit $exec
    %4:vgpr_32 = V_MOV_B32_e32 4, implicit $exec

    %5:agpr_32 = COPY %0
    %6:agpr_32 = COPY %1
    %7:agpr_32 = COPY %2
    %8:agpr_32 = COPY %3
    %9:agpr_32 = COPY %4

    S_NOP 0, implicit %5
    S_NOP 0, implicit %6
    S_NOP 0, implicit %7
    S_NOP 0, implicit %8
    S_NOP 0, implicit %9

...

