1 # RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx900 -run-pass si-optimize-exec-masking -verify-machineinstrs -o - %s | FileCheck %s
3 define amdgpu_kernel void @undefined_physreg_sgpr_spill() #0 {
7 define amdgpu_kernel void @undefined_physreg_sgpr_spill_reorder() #0 {
11 attributes #0 = { nounwind "amdgpu-num-sgpr"="16" }
16 # copy + s_and_b64 was turned into saveexec, deleting the copy,
17 # leaving a spill of the undefined register.
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
24 name: undefined_physreg_sgpr_spill
26 exposesReturnsTwice: false
28 regBankSelected: false
30 tracksRegLiveness: true
33 - { reg: '$vgpr0', virtual-reg: '' }
34 - { reg: '$sgpr4_sgpr5', virtual-reg: '' }
36 - { id: 0, name: '', type: spill-slot, offset: 0, size: 8, alignment: 4,
37 stack-id: sgpr-spill, callee-saved-register: '', callee-saved-restored: true,
38 debug-info-variable: '', debug-info-expression: '',
39 debug-info-location: '' }
43 successors: %bb.1, %bb.2
44 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
46 $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec
47 $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load (s8) from `i1 addrspace(4)* 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, 0, 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 (s64) 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 S_CBRANCH_EXECZ %bb.2, implicit $exec
59 successors: %bb.3(0x80000000)
60 liveins: $vgpr0, $vgpr1
62 $sgpr2_sgpr3 = S_MOV_B64 0
63 $vgpr2 = V_MOV_B32_e32 0, implicit $exec
64 $sgpr4_sgpr5 = IMPLICIT_DEF
69 liveins: $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
71 $sgpr0_sgpr1 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (load (s64) from %stack.0, align 4, addrspace 5)
72 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
75 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5
83 # Move spill to after future save instruction
84 # CHECK-LABEL: {{^}}name: undefined_physreg_sgpr_spill_reorder
85 # CHECK: $sgpr0_sgpr1 = COPY $exec, implicit-def $exec
86 # CHECK: $sgpr2_sgpr3 = S_AND_B64 $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc
87 # CHECK: SI_SPILL_S64_SAVE killed $sgpr0_sgpr1, %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (store (s64) into %stack.0, align 4, addrspace 5)
88 # CHECK: $exec = COPY killed $sgpr2_sgpr3
89 name: undefined_physreg_sgpr_spill_reorder
91 exposesReturnsTwice: false
93 regBankSelected: false
95 tracksRegLiveness: true
98 - { reg: '$vgpr0', virtual-reg: '' }
99 - { reg: '$sgpr4_sgpr5', virtual-reg: '' }
101 - { id: 0, name: '', type: spill-slot, offset: 0, size: 8, alignment: 4,
102 stack-id: sgpr-spill, callee-saved-register: '', callee-saved-restored: true,
103 debug-info-variable: '', debug-info-expression: '',
104 debug-info-location: '' }
108 successors: %bb.1, %bb.2
109 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
111 $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec
112 $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load (s8) from `i1 addrspace(4)* undef`)
113 $vcc = V_CMP_NE_U32_e64 0, $vgpr0, implicit $exec
114 $sgpr0_sgpr1 = V_CMP_EQ_U32_e64 1, killed $vgpr1, implicit $exec
115 $vgpr1 = V_CNDMASK_B32_e64 0, 0, 0, -1, killed $sgpr0_sgpr1, implicit $exec
116 $sgpr0_sgpr1 = COPY $exec, implicit-def $exec
117 $sgpr2_sgpr3 = S_AND_B64 $sgpr0_sgpr1, killed $vcc, implicit-def dead $scc
118 SI_SPILL_S64_SAVE killed $sgpr0_sgpr1, %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (store (s64) into %stack.0, align 4, addrspace 5)
119 $exec = S_MOV_B64_term killed $sgpr2_sgpr3
120 S_CBRANCH_EXECZ %bb.2, implicit $exec
124 successors: %bb.3(0x80000000)
125 liveins: $vgpr0, $vgpr1
127 $sgpr2_sgpr3 = S_MOV_B64 0
128 $vgpr2 = V_MOV_B32_e32 0, implicit $exec
129 $sgpr4_sgpr5 = IMPLICIT_DEF
134 liveins: $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
136 $sgpr0_sgpr1 = SI_SPILL_S64_RESTORE %stack.0, implicit $exec, implicit $sgpr8_sgpr9_sgpr10_sgpr11, implicit $sgpr13, implicit-def dead $m0 :: (load (s64) from %stack.0, align 4, addrspace 5)
137 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
140 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5