1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple=amdgcn -start-before=greedy -stop-after=virtregrewriter -stress-regalloc=3 -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN %s 3 4# Check that subreg use is live at the point of materialization, not just the main range. 5# Do not rematerialize if used subreg is dead at a new index. 6 7--- 8name: dead_subreg 9tracksRegLiveness: true 10body: | 11 bb.0.entry: 12 ; GCN-LABEL: name: dead_subreg 13 ; GCN: $m0 = IMPLICIT_DEF 14 ; GCN-NEXT: renamable $sgpr0_sgpr1 = S_MOV_B64 1, implicit $m0 15 ; GCN-NEXT: renamable $sgpr1 = S_MUL_I32 renamable $sgpr1, 3 16 ; GCN-NEXT: SI_SPILL_S32_SAVE killed renamable $sgpr1, %stack.0, implicit $exec, implicit $sp_reg :: (store (s32) into %stack.0, addrspace 5) 17 ; GCN-NEXT: renamable $sgpr2 = S_MOV_B32 2, implicit $m0 18 ; GCN-NEXT: renamable $sgpr1 = S_MOV_B32 3, implicit $m0 19 ; GCN-NEXT: dead [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 $sgpr0, implicit $exec, implicit killed $sgpr2, implicit killed $sgpr1 20 ; GCN-NEXT: renamable $sgpr1 = SI_SPILL_S32_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s32) from %stack.0, addrspace 5) 21 ; GCN-NEXT: dead [[V_MOV_B32_e32_1:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 killed $sgpr1, implicit $exec 22 ; GCN-NEXT: S_NOP 0, implicit killed renamable $sgpr0 23 $m0 = IMPLICIT_DEF 24 %0:sreg_64_xexec = S_MOV_B64 1, implicit $m0 25 %1:sreg_32 = S_MUL_I32 %0.sub1:sreg_64_xexec, 3 26 %2:sreg_32 = S_MOV_B32 2, implicit $m0 27 %3:sreg_32 = S_MOV_B32 3, implicit $m0 28 %4:vgpr_32 = V_MOV_B32_e32 %0.sub0:sreg_64_xexec, implicit $exec, implicit %2, implicit %3 29 %5:vgpr_32 = V_MOV_B32_e32 %1:sreg_32, implicit $exec 30 S_NOP 0, implicit %0.sub0 31... 32--- 33name: live_subreg 34tracksRegLiveness: true 35body: | 36 bb.0.entry: 37 ; GCN-LABEL: name: live_subreg 38 ; GCN: $m0 = IMPLICIT_DEF 39 ; GCN-NEXT: renamable $sgpr4_sgpr5 = S_MOV_B64 1, implicit $m0 40 ; GCN-NEXT: renamable $sgpr2 = S_MOV_B32 2, implicit $m0 41 ; GCN-NEXT: SI_SPILL_S32_SAVE killed renamable $sgpr2, %stack.0, implicit $exec, implicit $sp_reg :: (store (s32) into %stack.0, addrspace 5) 42 ; GCN-NEXT: renamable $sgpr2 = S_MOV_B32 3, implicit $m0 43 ; GCN-NEXT: renamable $sgpr0 = SI_SPILL_S32_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s32) from %stack.0, addrspace 5) 44 ; GCN-NEXT: dead [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 $sgpr4, implicit $exec, implicit killed $sgpr0, implicit killed $sgpr2 45 ; GCN-NEXT: renamable $sgpr0 = S_MUL_I32 renamable $sgpr5, 3 46 ; GCN-NEXT: dead [[V_MOV_B32_e32_1:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 killed $sgpr0, implicit $exec 47 ; GCN-NEXT: S_NOP 0, implicit killed renamable $sgpr5 48 $m0 = IMPLICIT_DEF 49 %0:sreg_64_xexec = S_MOV_B64 1, implicit $m0 50 %1:sreg_32 = S_MUL_I32 %0.sub1:sreg_64_xexec, 3 51 %2:sreg_32 = S_MOV_B32 2, implicit $m0 52 %3:sreg_32 = S_MOV_B32 3, implicit $m0 53 %4:vgpr_32 = V_MOV_B32_e32 %0.sub0:sreg_64_xexec, implicit $exec, implicit %2, implicit %3 54 %5:vgpr_32 = V_MOV_B32_e32 %1:sreg_32, implicit $exec 55 S_NOP 0, implicit %0.sub1 56... 57--- 58name: partially_live_wide_subreg 59tracksRegLiveness: true 60body: | 61 bb.0.entry: 62 ; GCN-LABEL: name: partially_live_wide_subreg 63 ; GCN: renamable $sgpr0_sgpr1 = IMPLICIT_DEF 64 ; GCN-NEXT: renamable $sgpr8_sgpr9_sgpr10_sgpr11 = S_LOAD_DWORDX4_IMM killed renamable $sgpr0_sgpr1, 1, 0 65 ; GCN-NEXT: renamable $sgpr4_sgpr5 = S_MOV_B64 renamable $sgpr10_sgpr11 66 ; GCN-NEXT: SI_SPILL_S64_SAVE killed renamable $sgpr4_sgpr5, %stack.0, implicit $exec, implicit $sp_reg :: (store (s64) into %stack.0, align 4, addrspace 5) 67 ; GCN-NEXT: renamable $sgpr4_sgpr5 = S_MOV_B64 3, implicit $m0 68 ; GCN-NEXT: renamable $sgpr0_sgpr1 = S_MOV_B64 2, implicit $m0 69 ; GCN-NEXT: dead [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 $sgpr8, implicit $exec, implicit killed $sgpr0_sgpr1, implicit killed $sgpr4_sgpr5 70 ; GCN-NEXT: renamable $sgpr4_sgpr5 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s64) from %stack.0, align 4, addrspace 5) 71 ; GCN-NEXT: dead [[V_MOV_B:%[0-9]+]]:vreg_64 = V_MOV_B64_PSEUDO killed $sgpr4_sgpr5, implicit $exec 72 ; GCN-NEXT: S_NOP 0, implicit killed renamable $sgpr8, implicit renamable $sgpr11 73 %0:sreg_64 = IMPLICIT_DEF 74 %1:sgpr_128 = S_LOAD_DWORDX4_IMM %0, 1, 0 75 %2:sreg_64 = S_MOV_B64 %1.sub2_sub3 76 %3:sreg_64 = S_MOV_B64 2, implicit $m0 77 %4:sreg_64 = S_MOV_B64 3, implicit $m0 78 %5:vgpr_32 = V_MOV_B32_e32 %1.sub0, implicit $exec, implicit %3, implicit %4 79 %6:vreg_64 = V_MOV_B64_PSEUDO %2, implicit $exec 80 S_NOP 0, implicit %1.sub0, implicit %1.sub3 81... 82--- 83name: dead_subreg_whole_reg 84tracksRegLiveness: true 85body: | 86 bb.0.entry: 87 ; GCN-LABEL: name: dead_subreg_whole_reg 88 ; GCN: $m0 = IMPLICIT_DEF 89 ; GCN-NEXT: renamable $sgpr0_sgpr1 = S_MOV_B64 1, implicit $m0 90 ; GCN-NEXT: renamable $sgpr2_sgpr3 = S_MOV_B64 renamable $sgpr0_sgpr1 91 ; GCN-NEXT: SI_SPILL_S64_SAVE killed renamable $sgpr2_sgpr3, %stack.0, implicit $exec, implicit $sp_reg :: (store (s64) into %stack.0, align 4, addrspace 5) 92 ; GCN-NEXT: renamable $sgpr4_sgpr5 = S_MOV_B64 2, implicit $m0 93 ; GCN-NEXT: renamable $sgpr2_sgpr3 = S_MOV_B64 3, implicit $m0 94 ; GCN-NEXT: dead [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 $sgpr0, implicit $exec, implicit killed $sgpr4_sgpr5, implicit killed $sgpr2_sgpr3 95 ; GCN-NEXT: renamable $sgpr2_sgpr3 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s64) from %stack.0, align 4, addrspace 5) 96 ; GCN-NEXT: dead [[V_MOV_B:%[0-9]+]]:vreg_64 = V_MOV_B64_PSEUDO killed $sgpr2_sgpr3, implicit $exec 97 ; GCN-NEXT: S_NOP 0, implicit killed renamable $sgpr0 98 $m0 = IMPLICIT_DEF 99 %0:sreg_64_xexec = S_MOV_B64 1, implicit $m0 100 %1:sreg_64 = S_MOV_B64 %0:sreg_64_xexec 101 %2:sreg_64 = S_MOV_B64 2, implicit $m0 102 %3:sreg_64 = S_MOV_B64 3, implicit $m0 103 %4:vgpr_32 = V_MOV_B32_e32 %0.sub0:sreg_64_xexec, implicit $exec, implicit %2, implicit %3 104 %5:vreg_64 = V_MOV_B64_PSEUDO %1, implicit $exec 105 S_NOP 0, implicit %0.sub0 106... 107