llvm/llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies-copy-to-sgpr.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
# RUN: llc -mtriple=amdgcn -mcpu=tonga -run-pass=si-fix-sgpr-copies --verify-machineinstrs -o - %s | FileCheck %s

# Copy to $sgpr0 is disconnected and becomes an IMPLICIT_DEF
# Inserted V_AND_B32 defines virtual register after use.

---
name:            si_fix_sgpr_copies_breaks_function
tracksRegLiveness: true
machineFunctionInfo:
  isEntryFunction: true
body:             |
  bb.0:
    liveins: $sgpr0

    ; CHECK-LABEL: name: si_fix_sgpr_copies_breaks_function
    ; CHECK: liveins: $sgpr0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr_32 = COPY $sgpr0
    ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 16
    ; CHECK-NEXT: [[S_LSHR_B32_:%[0-9]+]]:sreg_32 = S_LSHR_B32 [[COPY]], killed [[S_MOV_B32_]], implicit-def dead $scc
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY killed [[S_LSHR_B32_]]
    ; CHECK-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 -32768
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed [[S_MOV_B32_1]]
    ; CHECK-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 killed [[COPY1]], [[COPY2]], implicit $exec
    ; CHECK-NEXT: [[S_MOV_B32_2:%[0-9]+]]:sreg_32 = S_MOV_B32 65535
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
    ; CHECK-NEXT: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 killed [[S_MOV_B32_2]], [[V_XOR_B32_e64_]], implicit $exec
    ; CHECK-NEXT: $sgpr0 = V_READFIRSTLANE_B32 [[V_AND_B32_e64_]], implicit $exec
    ; CHECK-NEXT: SI_RETURN_TO_EPILOG $sgpr0
    %0:sgpr_32 = COPY $sgpr0
    %2:sreg_32 = S_MOV_B32 16
    %3:sreg_32 = S_LSHR_B32 %0, killed %2, implicit-def dead $scc
    %4:sreg_32 = COPY killed %3
    %5:sreg_32 = S_MOV_B32 -32768
    %7:vgpr_32 = COPY killed %5
    %6:vgpr_32 = V_XOR_B32_e64 killed %4, %7, implicit $exec
    %8:sreg_32 = S_MOV_B32 65535
    %10:sreg_32 = COPY %6
    %9:sreg_32 = S_AND_B32 killed %8, killed %10, implicit-def dead $scc
    $sgpr0 = COPY %9
    SI_RETURN_TO_EPILOG $sgpr0

...