1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=WAVE64 %s
3# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64  -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=WAVE32 %s
4
5---
6
7name:            copy
8legalized:       true
9regBankSelected: true
10
11
12body: |
13  bb.0:
14    liveins: $sgpr2_sgpr3
15
16    ; WAVE64-LABEL: name: copy
17    ; WAVE64: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
18    ; WAVE64: [[COPY1:%[0-9]+]]:vreg_64 = COPY [[COPY]]
19    ; WAVE64: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
20    ; WAVE64: FLAT_STORE_DWORD [[COPY1]], [[DEF]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
21    ; WAVE32-LABEL: name: copy
22    ; WAVE32: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
23    ; WAVE32: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
24    ; WAVE32: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
25    ; WAVE32: GLOBAL_STORE_DWORD_SADDR [[V_MOV_B32_e32_]], [[DEF]], [[COPY]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
26    %0:sgpr(p1) = COPY $sgpr2_sgpr3
27    %1:vgpr(p1) = COPY %0
28    %2:vgpr(s32) = G_IMPLICIT_DEF
29    G_STORE %2, %1 :: (store 4, addrspace 1)
30...
31---
32
33name:            copy_vcc_bank_sgpr_bank
34legalized:       true
35regBankSelected: true
36
37body: |
38  bb.0:
39    liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
40
41    ; WAVE64-LABEL: name: copy_vcc_bank_sgpr_bank
42    ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
43    ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
44    ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
45    ; WAVE64: [[COPY3:%[0-9]+]]:sreg_32 = COPY $scc
46    ; WAVE64: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY3]], implicit-def $scc
47    ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
48    ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
49    ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
50    ; WAVE32-LABEL: name: copy_vcc_bank_sgpr_bank
51    ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
52    ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
53    ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
54    ; WAVE32: [[COPY3:%[0-9]+]]:sreg_32 = COPY $scc
55    ; WAVE32: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY3]], implicit-def $scc
56    ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32_xm0_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
57    ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
58    ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
59    %0:vgpr(p1) = COPY $vgpr0_vgpr1
60    %1:vgpr(s32) = COPY $vgpr2
61    %2:vgpr(s32) = COPY $vgpr3
62    %3:sgpr(s1) = COPY $scc
63    %4:vcc(s1) = COPY %3
64    %5:vgpr(s32) = G_SELECT %4, %1, %2
65    G_STORE %5, %0 :: (store 4, addrspace 1)
66...
67---
68
69name:            copy_vcc_bank_sgpr_bank_2_uses
70legalized:       true
71regBankSelected: true
72
73body: |
74  bb.0:
75    liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
76
77    ; WAVE64-LABEL: name: copy_vcc_bank_sgpr_bank_2_uses
78    ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
79    ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
80    ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
81    ; WAVE64: [[COPY3:%[0-9]+]]:sreg_32 = COPY $scc
82    ; WAVE64: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY3]], implicit-def $scc
83    ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
84    ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
85    ; WAVE64: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY3]], implicit-def $scc
86    ; WAVE64: [[V_CMP_NE_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_1]], implicit $exec
87    ; WAVE64: [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_CNDMASK_B32_e64_]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_1]], implicit $exec
88    ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_1]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
89    ; WAVE32-LABEL: name: copy_vcc_bank_sgpr_bank_2_uses
90    ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
91    ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
92    ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
93    ; WAVE32: [[COPY3:%[0-9]+]]:sreg_32 = COPY $scc
94    ; WAVE32: [[COPY4:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[COPY3]]
95    ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY4]], implicit $exec
96    ; WAVE32: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY3]], implicit-def $scc
97    ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32_xm0_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
98    ; WAVE32: [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_CNDMASK_B32_e64_]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
99    ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_1]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
100    %0:vgpr(p1) = COPY $vgpr0_vgpr1
101    %1:vgpr(s32) = COPY $vgpr2
102    %2:vgpr(s32) = COPY $vgpr3
103    %3:sgpr(s1) = COPY $scc
104    %4:vcc(s1) = COPY %3
105    %5:vgpr(s32) = G_SELECT %4, %1, %2
106    %6:vcc(s1) = COPY %3
107    %7:vgpr(s32) = G_SELECT %6, %1, %5
108    G_STORE %7, %0 :: (store 4, addrspace 1)
109...
110
111---
112
113name:            copy_vcc_bank_scc_physreg
114legalized:       true
115regBankSelected: true
116
117body: |
118  bb.0:
119    liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
120
121    ; WAVE64-LABEL: name: copy_vcc_bank_scc_physreg
122    ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
123    ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
124    ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
125    ; WAVE64: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY $scc
126    ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY3]], implicit $exec
127    ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
128    ; WAVE32-LABEL: name: copy_vcc_bank_scc_physreg
129    ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
130    ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
131    ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
132    ; WAVE32: [[COPY3:%[0-9]+]]:sreg_32_xm0_xexec = COPY $scc
133    ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY3]], implicit $exec
134    ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
135    %0:vgpr(p1) = COPY $vgpr0_vgpr1
136    %1:vgpr(s32) = COPY $vgpr2
137    %2:vgpr(s32) = COPY $vgpr3
138    %3:vcc(s1) = COPY $scc
139    %5:vgpr(s32) = G_SELECT %3, %1, %2
140    G_STORE %5, %0 :: (store 4, addrspace 1)
141...
142---
143
144name:            copy_sgpr_no_type
145legalized:       true
146regBankSelected: true
147
148
149body: |
150  bb.0:
151    liveins: $sgpr0
152    ; WAVE64-LABEL: name: copy_sgpr_no_type
153    ; WAVE64: [[COPY:%[0-9]+]]:sreg_32_xm0 = COPY $sgpr0
154    ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
155    ; WAVE32-LABEL: name: copy_sgpr_no_type
156    ; WAVE32: [[COPY:%[0-9]+]]:sreg_32_xm0 = COPY $sgpr0
157    ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
158    %0:sreg_32_xm0 = COPY $sgpr0
159    %1:sreg_32_xm0 = COPY %0
160    S_ENDPGM 0, implicit %1
161
162...
163
164---
165
166name:            copy_vgpr_no_type
167legalized:       true
168regBankSelected: true
169
170
171body: |
172  bb.0:
173    liveins: $vgpr0
174    ; WAVE64-LABEL: name: copy_vgpr_no_type
175    ; WAVE64: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
176    ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
177    ; WAVE32-LABEL: name: copy_vgpr_no_type
178    ; WAVE32: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
179    ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
180    %0:vgpr_32 = COPY $vgpr0
181    %1:vgpr_32 = COPY %0
182    S_ENDPGM 0, implicit %1
183
184...
185
186---
187
188name:            copy_maybe_vcc
189legalized:       true
190regBankSelected: true
191
192
193body: |
194  bb.0:
195    liveins: $sgpr0_sgpr1
196    ; WAVE64-LABEL: name: copy_maybe_vcc
197    ; WAVE64: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr0_sgpr1
198    ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
199    ; WAVE32-LABEL: name: copy_maybe_vcc
200    ; WAVE32: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr0_sgpr1
201    ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
202    %0:sreg_64_xexec = COPY $sgpr0_sgpr1
203    %1:sreg_64_xexec = COPY %0
204    S_ENDPGM 0, implicit %1
205
206...
207
208# FIXME: This is malformed. There should never be a trunc to vcc.
209---
210
211name:            copy_s1_vcc_to_vcc
212legalized:       true
213regBankSelected: true
214
215
216body: |
217  bb.0:
218    liveins: $sgpr0_sgpr1
219
220    ; WAVE64-LABEL: name: copy_s1_vcc_to_vcc
221    ; WAVE64: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
222    ; WAVE64: [[COPY1:%[0-9]+]]:sreg_64_xexec = COPY [[COPY]]
223    ; WAVE64: S_ENDPGM 0, implicit [[COPY1]]
224    ; WAVE32-LABEL: name: copy_s1_vcc_to_vcc
225    ; WAVE32: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
226    ; WAVE32: [[COPY1:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[COPY]]
227    ; WAVE32: S_ENDPGM 0, implicit [[COPY1]]
228    %0:sgpr(s32) = COPY $sgpr0
229    %1:vcc(s1) = G_TRUNC %0
230    %2:vcc(s1) = COPY %1
231    S_ENDPGM 0, implicit %2
232
233...
234
235---
236
237name:            copy_s64_to_vcc
238legalized:       true
239regBankSelected: true
240
241
242body: |
243  bb.0:
244    liveins: $sgpr0_sgpr1
245    ; WAVE64-LABEL: name: copy_s64_to_vcc
246    ; WAVE64: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
247    ; WAVE64: $vcc = COPY [[COPY]]
248    ; WAVE64: S_ENDPGM 0, implicit $vcc
249    ; WAVE32-LABEL: name: copy_s64_to_vcc
250    ; WAVE32: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
251    ; WAVE32: $vcc = COPY [[COPY]]
252    ; WAVE32: S_ENDPGM 0, implicit $vcc_lo
253    %0:sgpr(s64) = COPY $sgpr0_sgpr1
254    $vcc = COPY %0
255    S_ENDPGM 0, implicit $vcc
256
257...
258
259---
260
261name:            copy_s32_to_vcc_lo
262legalized:       true
263regBankSelected: true
264
265
266body: |
267  bb.0:
268    liveins: $sgpr0
269    ; WAVE64-LABEL: name: copy_s32_to_vcc_lo
270    ; WAVE64: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
271    ; WAVE64: $vcc_lo = COPY [[COPY]]
272    ; WAVE64: S_ENDPGM 0, implicit $vcc
273    ; WAVE32-LABEL: name: copy_s32_to_vcc_lo
274    ; WAVE32: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
275    ; WAVE32: $vcc_lo = COPY [[COPY]]
276    ; WAVE32: S_ENDPGM 0, implicit $vcc_lo
277    %0:sgpr(s32) = COPY $sgpr0
278    $vcc_lo = COPY %0
279    S_ENDPGM 0, implicit $vcc
280
281...
282
283---
284
285name:            copy_vcc_to_s64
286legalized:       true
287regBankSelected: true
288
289
290body: |
291  bb.0:
292    liveins: $vcc
293    ; WAVE64-LABEL: name: copy_vcc_to_s64
294    ; WAVE64: [[COPY:%[0-9]+]]:sreg_64 = COPY $vcc
295    ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
296    ; WAVE32-LABEL: name: copy_vcc_to_s64
297    ; WAVE32: [[COPY:%[0-9]+]]:sreg_64 = COPY $vcc
298    ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
299    %0:sgpr(s64) = COPY $vcc
300    S_ENDPGM 0, implicit %0
301
302...
303
304---
305
306name:            copy_vcc_lo_to_s32
307legalized:       true
308regBankSelected: true
309
310
311body: |
312  bb.0:
313    liveins: $vcc
314    ; WAVE64-LABEL: name: copy_vcc_lo_to_s32
315    ; WAVE64: [[COPY:%[0-9]+]]:sreg_32 = COPY $vcc_lo
316    ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
317    ; WAVE32-LABEL: name: copy_vcc_lo_to_s32
318    ; WAVE32: [[COPY:%[0-9]+]]:sreg_32 = COPY $vcc_lo
319    ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
320    %0:sgpr(s32) = COPY $vcc_lo
321    S_ENDPGM 0, implicit %0
322
323...
324