• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:       1
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: sgpr-spill, 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, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
45
46    $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec
47    $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load 1 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 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    liveins: $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
70
71    $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)
72    $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
73
74  bb.3:
75    liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5
76
77    $vcc = COPY $vgpr1
78    S_ENDPGM 0
79
80...
81---
82
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 8 into %stack.0, align 4, addrspace 5)
88# CHECK: $exec = COPY killed $sgpr2_sgpr3
89name:            undefined_physreg_sgpr_spill_reorder
90alignment:       1
91exposesReturnsTwice: false
92legalized:       false
93regBankSelected: false
94selected:        false
95tracksRegLiveness: true
96registers:
97liveins:
98  - { reg: '$vgpr0', virtual-reg: '' }
99  - { reg: '$sgpr4_sgpr5', virtual-reg: '' }
100stack:
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: '' }
105constants:
106body:             |
107  bb.0:
108    successors: %bb.1, %bb.2
109    liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
110
111    $vgpr1_vgpr2 = COPY killed $sgpr4_sgpr5, implicit $exec
112    $vgpr1 = GLOBAL_LOAD_UBYTE killed $vgpr1_vgpr2, 0, 0, 0, 0, implicit $exec :: (non-temporal dereferenceable invariant load 1 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 8 into %stack.0, align 4, addrspace 5)
119    $exec = S_MOV_B64_term killed $sgpr2_sgpr3
120    SI_MASK_BRANCH %bb.2, implicit $exec
121    S_BRANCH %bb.1
122
123  bb.1:
124    successors: %bb.3(0x80000000)
125    liveins: $vgpr0, $vgpr1
126
127    $sgpr2_sgpr3 = S_MOV_B64 0
128    $vgpr2 = V_MOV_B32_e32 0, implicit $exec
129    $sgpr4_sgpr5 = IMPLICIT_DEF
130    S_BRANCH %bb.3
131
132  bb.2:
133    successors:
134    liveins: $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr13
135
136    $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)
137    $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
138
139  bb.3:
140    liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr2_sgpr3, $sgpr4_sgpr5
141
142    $vcc = COPY $vgpr1
143    S_ENDPGM 0
144
145...
146