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
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, implicit $exec, implicit $flat_scr :: (store (s32), 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, implicit $exec :: (store (s32), addrspace 1)
26 %0:sgpr(p1) = COPY $sgpr2_sgpr3
28 %2:vgpr(s32) = G_IMPLICIT_DEF
29 G_STORE %2, %1 :: (store (s32), addrspace 1)
33 name: copy_vcc_bank_sgpr_bank
39 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
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, implicit $exec, implicit $flat_scr :: (store (s32), 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, implicit $exec :: (store (s32), 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
64 %5:vgpr(s32) = G_SELECT %4, %1, %2
65 G_STORE %5, %0 :: (store (s32), addrspace 1)
69 name: copy_vcc_bank_sgpr_bank_2_uses
75 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
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, implicit $exec, implicit $flat_scr :: (store (s32), 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, implicit $exec :: (store (s32), 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
105 %5:vgpr(s32) = G_SELECT %4, %1, %2
107 %7:vgpr(s32) = G_SELECT %6, %1, %5
108 G_STORE %7, %0 :: (store (s32), addrspace 1)
113 name: copy_vcc_bank_scc_physreg
115 regBankSelected: true
119 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
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, implicit $exec, implicit $flat_scr :: (store (s32), 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, implicit $exec :: (store (s32), 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 (s32), addrspace 1)
144 name: copy_sgpr_no_type
146 regBankSelected: true
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
166 name: copy_vgpr_no_type
168 regBankSelected: true
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
182 S_ENDPGM 0, implicit %1
190 regBankSelected: true
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
208 # FIXME: This is malformed. There should never be a trunc to vcc.
211 name: copy_s1_vcc_to_vcc
213 regBankSelected: true
218 liveins: $sgpr0_sgpr1
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
231 S_ENDPGM 0, implicit %2
237 name: copy_s64_to_vcc
239 regBankSelected: true
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
255 S_ENDPGM 0, implicit $vcc
261 name: copy_s32_to_vcc_lo
263 regBankSelected: true
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
279 S_ENDPGM 0, implicit $vcc
285 name: copy_vcc_to_s64
287 regBankSelected: true
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
306 name: copy_vcc_lo_to_s32
308 regBankSelected: true
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
329 regBankSelected: true
330 tracksRegLiveness: true
333 liveins: $sgpr0_sgpr1
335 ; WAVE64-LABEL: name: copy_s1_to_vcc
336 ; WAVE64: liveins: $sgpr0_sgpr1
337 ; WAVE64: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
338 ; WAVE64: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
339 ; WAVE64: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY1]], implicit-def $scc
340 ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
341 ; WAVE64: S_ENDPGM 0, implicit [[V_CMP_NE_U32_e64_]]
342 ; WAVE32-LABEL: name: copy_s1_to_vcc
343 ; WAVE32: liveins: $sgpr0_sgpr1
344 ; WAVE32: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
345 ; WAVE32: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
346 ; WAVE32: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY1]], implicit-def $scc
347 ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
348 ; WAVE32: S_ENDPGM 0, implicit [[V_CMP_NE_U32_e64_]]
349 %0:sgpr(s64) = COPY $sgpr0_sgpr1
350 %1:sgpr(s1) = G_TRUNC %0(s64)
351 %2:vcc(s1) = COPY %1(s1)
352 S_ENDPGM 0, implicit %2
358 name: copy_s1_false_to_vcc
360 regBankSelected: true
361 tracksRegLiveness: true
366 ; WAVE64-LABEL: name: copy_s1_false_to_vcc
367 ; WAVE64: liveins: $sgpr0
368 ; WAVE64: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 0
369 ; WAVE64: S_ENDPGM 0, implicit [[S_MOV_B64_]]
370 ; WAVE32-LABEL: name: copy_s1_false_to_vcc
371 ; WAVE32: liveins: $sgpr0
372 ; WAVE32: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
373 ; WAVE32: S_ENDPGM 0, implicit [[S_MOV_B32_]]
374 %0:sgpr(s1) = G_CONSTANT i1 false
375 %1:vcc(s1) = COPY %0(s1)
376 S_ENDPGM 0, implicit %1
382 name: copy_s1_true_to_vcc
384 regBankSelected: true
385 tracksRegLiveness: true
390 ; WAVE64-LABEL: name: copy_s1_true_to_vcc
391 ; WAVE64: liveins: $sgpr0
392 ; WAVE64: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 -1
393 ; WAVE64: S_ENDPGM 0, implicit [[S_MOV_B64_]]
394 ; WAVE32-LABEL: name: copy_s1_true_to_vcc
395 ; WAVE32: liveins: $sgpr0
396 ; WAVE32: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 -1
397 ; WAVE32: S_ENDPGM 0, implicit [[S_MOV_B32_]]
398 %0:sgpr(s1) = G_CONSTANT i1 true
399 %1:vcc(s1) = COPY %0(s1)
400 S_ENDPGM 0, implicit %1