1# RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx900 -run-pass si-optimize-exec-masking -verify-machineinstrs -o - %s | FileCheck %s 2--- | 3 define amdgpu_kernel void @undefined_physreg_sgpr_spill() #0 { 4 unreachable 5 } 6 7 define amdgpu_kernel void @undefined_physreg_sgpr_spill_reorder() #0 { 8 unreachable 9 } 10 11 attributes #0 = { nounwind "amdgpu-num-sgpr"="16" } 12 13... 14--- 15 16# copy + s_and_b64 was turned into saveexec, deleting the copy, 17# leaving a spill of the undefined register. 18 19# CHECK-LABEL: name: undefined_physreg_sgpr_spill 20# CHECK: $sgpr0_sgpr1 = COPY $exec, implicit-def $exec 21# CHECK-NEXT: SI_SPILL_S64_SAVE $sgpr0_sgpr1, 22# CHECK-NEXT: $sgpr2_sgpr3 = S_AND_B64 killed $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc 23# CHECK: $exec = COPY killed $sgpr2_sgpr3 24name: undefined_physreg_sgpr_spill 25alignment: 0 26exposesReturnsTwice: false 27legalized: false 28regBankSelected: false 29selected: false 30tracksRegLiveness: true 31registers: 32liveins: 33 - { reg: '$vgpr0', virtual-reg: '' } 34 - { reg: '$sgpr4_sgpr5', virtual-reg: '' } 35stack: 36 - { id: 0, name: '', type: spill-slot, offset: 0, size: 8, alignment: 4, 37 stack-id: 1, callee-saved-register: '', callee-saved-restored: true, 38 debug-info-variable: '', debug-info-expression: '', 39 debug-info-location: '' } 40constants: 41body: | 42 bb.0: 43 successors: %bb.1, %bb.2 44 liveins: $vgpr0, $sgpr4_sgpr5 45 46 $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec 47 $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load 1 from `i1 addrspace(2)* undef`) 48 $vcc = V_CMP_NE_U32_e64 0, $vgpr0, implicit $exec 49 $sgpr0_sgpr1 = V_CMP_EQ_U32_e64 1, killed $vgpr1, implicit $exec 50 $vgpr1 = V_CNDMASK_B32_e64 0, -1, killed $sgpr0_sgpr1, implicit $exec 51 $sgpr0_sgpr1 = COPY $exec, implicit-def $exec 52 SI_SPILL_S64_SAVE $sgpr0_sgpr1, %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (store 8 into %stack.0, align 4, addrspace 5) 53 $sgpr2_sgpr3 = S_AND_B64 killed $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc 54 $exec = S_MOV_B64_term killed $sgpr2_sgpr3 55 SI_MASK_BRANCH %bb.2, implicit $exec 56 S_BRANCH %bb.1 57 58 bb.1: 59 successors: %bb.3(0x80000000) 60 liveins: $vgpr0, $vgpr1 61 62 $sgpr2_sgpr3 = S_MOV_B64 0 63 $vgpr2 = V_MOV_B32_e32 0, implicit $exec 64 $sgpr4_sgpr5 = IMPLICIT_DEF 65 S_BRANCH %bb.3 66 67 bb.2: 68 successors: 69 70 $sgpr0_sgpr1 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (load 8 from %stack.0, align 4, addrspace 5) 71 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc 72 73 bb.3: 74 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5 75 76 $vcc = COPY $vgpr1 77 S_ENDPGM 78 79... 80--- 81 82# Move spill to after future save instruction 83# CHECK-LABEL: {{^}}name: undefined_physreg_sgpr_spill_reorder 84# CHECK: $sgpr0_sgpr1 = COPY $exec, implicit-def $exec 85# CHECK: $sgpr2_sgpr3 = S_AND_B64 $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc 86# CHECK: SI_SPILL_S64_SAVE killed $sgpr0_sgpr1, %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (store 8 into %stack.0, align 4, addrspace 5) 87# CHECK: $exec = COPY killed $sgpr2_sgpr3 88name: undefined_physreg_sgpr_spill_reorder 89alignment: 0 90exposesReturnsTwice: false 91legalized: false 92regBankSelected: false 93selected: false 94tracksRegLiveness: true 95registers: 96liveins: 97 - { reg: '$vgpr0', virtual-reg: '' } 98 - { reg: '$sgpr4_sgpr5', virtual-reg: '' } 99stack: 100 - { id: 0, name: '', type: spill-slot, offset: 0, size: 8, alignment: 4, 101 stack-id: 1, callee-saved-register: '', callee-saved-restored: true, 102 debug-info-variable: '', debug-info-expression: '', 103 debug-info-location: '' } 104constants: 105body: | 106 bb.0: 107 successors: %bb.1, %bb.2 108 liveins: $vgpr0, $sgpr4_sgpr5 109 110 $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec 111 $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load 1 from `i1 addrspace(2)* undef`) 112 $vcc = V_CMP_NE_U32_e64 0, $vgpr0, implicit $exec 113 $sgpr0_sgpr1 = V_CMP_EQ_U32_e64 1, killed $vgpr1, implicit $exec 114 $vgpr1 = V_CNDMASK_B32_e64 0, -1, killed $sgpr0_sgpr1, implicit $exec 115 $sgpr0_sgpr1 = COPY $exec, implicit-def $exec 116 $sgpr2_sgpr3 = S_AND_B64 $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc 117 SI_SPILL_S64_SAVE killed $sgpr0_sgpr1, %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (store 8 into %stack.0, align 4, addrspace 5) 118 $exec = S_MOV_B64_term killed $sgpr2_sgpr3 119 SI_MASK_BRANCH %bb.2, implicit $exec 120 S_BRANCH %bb.1 121 122 bb.1: 123 successors: %bb.3(0x80000000) 124 liveins: $vgpr0, $vgpr1 125 126 $sgpr2_sgpr3 = S_MOV_B64 0 127 $vgpr2 = V_MOV_B32_e32 0, implicit $exec 128 $sgpr4_sgpr5 = IMPLICIT_DEF 129 S_BRANCH %bb.3 130 131 bb.2: 132 successors: 133 134 $sgpr0_sgpr1 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (load 8 from %stack.0, align 4, addrspace 5) 135 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc 136 137 bb.3: 138 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5 139 140 $vcc = COPY $vgpr1 141 S_ENDPGM 142 143... 144