1 # RUN: llc -march=amdgcn -amdgpu-enable-merge-m0 -verify-machineinstrs -run-pass si-fix-sgpr-copies %s -o - | FileCheck -check-prefix=GCN %s
3 # GCN-LABEL: name: merge-m0-many-init
6 # GCN-NEXT: IMPLICIT_DEF
7 # GCN-NEXT: IMPLICIT_DEF
8 # GCN-NEXT: DS_WRITE_B32
9 # GCN-NEXT: DS_WRITE_B32
10 # GCN-NEXT: SI_INIT_M0 65536
11 # GCN-NEXT: DS_WRITE_B32
12 # GCN-NEXT: DS_WRITE_B32
13 # GCN-NEXT: SI_INIT_M0 -1
14 # GCN-NEXT: DS_WRITE_B32
15 # GCN-NEXT: SI_INIT_M0 65536
16 # GCN-NEXT: DS_WRITE_B32
20 # GCN-NEXT: DS_WRITE_B32
21 # GCN-NEXT: DS_WRITE_B32
24 # GCN: SI_INIT_M0 65536
25 # GCN-NEXT: DS_WRITE_B32
33 # GCN-NEXT: SI_INIT_M0 4
34 # GCN-NEXT: DS_WRITE_B32
39 # GCN-NEXT: SI_INIT_M0 4
40 # GCN-NEXT: DS_WRITE_B32
44 # GCN-NEXT: DS_WRITE_B32
46 # GCN-NEXT: DS_WRITE_B32
47 # GCN-NEXT: SI_INIT_M0 %2
48 # GCN-NEXT: DS_WRITE_B32
49 # GCN-NEXT: SI_INIT_M0 -1
50 # GCN-NEXT: DS_WRITE_B32
52 name: merge-m0-many-init
54 - { id: 0, class: vgpr_32 }
55 - { id: 1, class: vgpr_32 }
56 - { id: 2, class: sreg_32_xm0 }
59 successors: %bb.1, %bb.2
63 SI_INIT_M0 -1, implicit-def $m0
64 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
65 SI_INIT_M0 -1, implicit-def $m0
66 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
67 SI_INIT_M0 65536, implicit-def $m0
68 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
69 SI_INIT_M0 65536, implicit-def $m0
70 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
71 SI_INIT_M0 -1, implicit-def $m0
72 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
73 SI_INIT_M0 65536, implicit-def $m0
74 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
75 S_CBRANCH_VCCZ %bb.1, implicit undef $vcc
80 SI_INIT_M0 -1, implicit-def $m0
81 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
82 SI_INIT_M0 -1, implicit-def $m0
83 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
88 SI_INIT_M0 65536, implicit-def $m0
89 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
93 successors: %bb.4, %bb.5
94 S_CBRANCH_VCCZ %bb.4, implicit undef $vcc
99 SI_INIT_M0 3, implicit-def $m0
100 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
101 SI_INIT_M0 4, implicit-def $m0
102 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
107 SI_INIT_M0 3, implicit-def $m0
108 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
109 SI_INIT_M0 4, implicit-def $m0
110 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
114 successors: %bb.0.entry, %bb.6
115 SI_INIT_M0 -1, implicit-def $m0
116 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
118 SI_INIT_M0 %2, implicit-def $m0
119 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
120 SI_INIT_M0 %2, implicit-def $m0
121 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
122 SI_INIT_M0 -1, implicit-def $m0
123 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
124 S_CBRANCH_VCCZ %bb.6, implicit undef $vcc
129 # GCN-LABEL: name: merge-m0-dont-hoist-past-init-with-different-initializer
131 # GCN: SI_INIT_M0 65536
132 # GCN-NEXT: IMPLICIT_DEF
133 # GCN-NEXT: IMPLICIT_DEF
134 # GCN-NEXT: DS_WRITE_B32
137 # GCN-NOT: SI_INIT_M0 65536
138 # GCN-NOT: SI_INIT_M0 -1
146 name: merge-m0-dont-hoist-past-init-with-different-initializer
148 - { id: 0, class: vgpr_32 }
149 - { id: 1, class: vgpr_32 }
156 SI_INIT_M0 65536, implicit-def $m0
157 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
161 successors: %bb.2, %bb.3
163 SI_INIT_M0 65536, implicit-def $m0
164 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
165 S_CBRANCH_VCCZ %bb.2, implicit undef $vcc
171 SI_INIT_M0 -1, implicit-def $m0
172 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
178 SI_INIT_M0 -1, implicit-def $m0
179 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
186 # GCN-LABEL: name: merge-m0-after-prologue
188 # GCN-NOT: SI_INIT_M0
190 # GCN-NEXT: SI_INIT_M0
193 # GCN-NOT: SI_INIT_M0 -1
196 # GCN-NOT: SI_INIT_MO -1
198 name: merge-m0-after-prologue
200 - { id: 0, class: vgpr_32 }
201 - { id: 1, class: vgpr_32 }
204 successors: %bb.1, %bb.2
205 liveins: $sgpr0_sgpr1
207 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
210 S_CBRANCH_VCCZ %bb.1, implicit undef $vcc
216 SI_INIT_M0 -1, implicit-def $m0
217 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
223 SI_INIT_M0 -1, implicit-def $m0
224 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
231 # GCN-LABEL: name: move-m0-avoid-hazard
232 # GCN: $m0 = S_MOV_B32 -1
233 # GCN-NEXT: $vgpr0 = V_MOV_B32_e32 0, implicit $exec
234 # GCN-NEXT: DS_GWS_INIT $vgpr0, 0, 1, implicit $m0, implicit $exec
236 name: move-m0-avoid-hazard
239 $vgpr0 = V_MOV_B32_e32 0, implicit $exec
241 DS_GWS_INIT $vgpr0, 0, 1, implicit $m0, implicit $exec
244 # GCN-LABEL: name: move-m0-with-prologue
245 # GCN $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
246 # GCN: $m0 = S_MOV_B32 -1
247 # GCN-NEXT: $vgpr0 = V_MOV_B32_e32 0, implicit $exec
248 # GCN-NEXT: DS_GWS_INIT $vgpr0, 0, 1, implicit $m0, implicit $exec
250 name: move-m0-with-prologue
253 liveins: $sgpr0_sgpr1
255 $exec = S_OR_B64 $exec, killed $sgpr0_sgpr1, implicit-def $scc
256 $vgpr0 = V_MOV_B32_e32 0, implicit $exec
258 DS_GWS_INIT $vgpr0, 0, 1, implicit $m0, implicit $exec
261 # GCN-LABEL: name: move-m0-different-initializer
263 # GCN-NEXT: %0:vgpr_32 = IMPLICIT_DEF
264 # GCN: SI_INIT_M0 65536
267 name: move-m0-different-initializer
269 - { id: 0, class: vgpr_32 }
270 - { id: 1, class: vgpr_32 }
275 SI_INIT_M0 -1, implicit-def $m0
276 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
278 SI_INIT_M0 65536, implicit-def $m0
279 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec
282 # GCN-LABEL: name: move-m0-schedule-boundary
284 # GCN-NEXT: SI_INIT_M0 -1
286 name: move-m0-schedule-boundary
288 - { id: 0, class: vgpr_32 }
289 - { id: 1, class: vgpr_32 }
294 S_SETREG_IMM32_B32 0, 1
295 SI_INIT_M0 -1, implicit-def $m0
296 DS_WRITE_B32 %0, %1, 0, 0, implicit $m0, implicit $exec