1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -run-pass=instruction-select -global-isel-abort=2 -pass-remarks-missed='gisel*' -verify-machineinstrs %s -o - 2> %t | FileCheck -check-prefixes=GCN %s
3 # RUN: FileCheck -check-prefix=ERR %s < %t
6 # ERR: remark: <unknown>:0:0: cannot select: G_BRCOND %1:sgpr(s1), %bb.1 (in function: brcond_sgpr)
7 # ERR-NEXT: remark: <unknown>:0:0: cannot select: G_BRCOND %1:vgpr(s1), %bb.1 (in function: brcond_vgpr)
17 ; GCN-LABEL: name: brcond_scc
19 ; GCN-NEXT: successors: %bb.1(0x80000000)
20 ; GCN-NEXT: liveins: $sgpr0, $sgpr1
22 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
23 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
24 ; GCN-NEXT: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
25 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $scc
26 ; GCN-NEXT: $scc = COPY [[COPY2]]
27 ; GCN-NEXT: S_CBRANCH_SCC1 %bb.1, implicit $scc
31 liveins: $sgpr0, $sgpr1
33 %0:sgpr(s32) = COPY $sgpr0
34 %1:sgpr(s32) = COPY $sgpr1
35 %2:sgpr(s32) = G_ICMP intpred(eq), %0, %1
44 name: brcond_scc_impdef
49 ; GCN-LABEL: name: brcond_scc_impdef
51 ; GCN-NEXT: successors: %bb.1(0x80000000)
52 ; GCN-NEXT: liveins: $sgpr0, $sgpr1
54 ; GCN-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
55 ; GCN-NEXT: $scc = COPY [[DEF]]
56 ; GCN-NEXT: S_CBRANCH_SCC1 %bb.1, implicit $scc
60 liveins: $sgpr0, $sgpr1
62 %0:sgpr(s32) = G_IMPLICIT_DEF
76 ; GCN-LABEL: name: brcond_scc_br
78 ; GCN-NEXT: successors: %bb.1(0x80000000)
79 ; GCN-NEXT: liveins: $sgpr0, $sgpr1
81 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
82 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
83 ; GCN-NEXT: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
84 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $scc
85 ; GCN-NEXT: $scc = COPY [[COPY2]]
86 ; GCN-NEXT: S_CBRANCH_SCC1 %bb.1, implicit $scc
87 ; GCN-NEXT: S_BRANCH %bb.1
90 ; GCN-NEXT: successors: %bb.2(0x80000000)
95 liveins: $sgpr0, $sgpr1
97 %0:sgpr(s32) = COPY $sgpr0
98 %1:sgpr(s32) = COPY $sgpr1
99 %2:sgpr(s32) = G_ICMP intpred(eq), %0, %1
113 regBankSelected: true
116 ; GCN-LABEL: name: brcond_vcc
118 ; GCN-NEXT: successors: %bb.1(0x80000000)
119 ; GCN-NEXT: liveins: $vgpr0, $vgpr1
121 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
122 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
123 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
124 ; GCN-NEXT: $vcc = COPY [[V_CMP_EQ_U32_e64_]]
125 ; GCN-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
129 liveins: $vgpr0, $vgpr1
131 %0:vgpr(s32) = COPY $vgpr0
132 %1:vgpr(s32) = COPY $vgpr1
133 %2:vcc(s1) = G_ICMP intpred(eq), %0, %1
140 # Don't try to select this.
145 regBankSelected: true
148 ; GCN-LABEL: name: brcond_sgpr
150 ; GCN-NEXT: successors: %bb.1(0x80000000)
151 ; GCN-NEXT: liveins: $sgpr0, $sgpr1
153 ; GCN-NEXT: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
154 ; GCN-NEXT: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY]](s32)
155 ; GCN-NEXT: G_BRCOND [[TRUNC]](s1), %bb.1
159 liveins: $sgpr0, $sgpr1
161 %0:sgpr(s32) = COPY $sgpr0
162 %1:sgpr(s1) = G_TRUNC %0
169 # Don't try to select this.
174 regBankSelected: true
177 ; GCN-LABEL: name: brcond_vgpr
179 ; GCN-NEXT: successors: %bb.1(0x80000000)
180 ; GCN-NEXT: liveins: $vgpr0, $vgpr1
182 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
183 ; GCN-NEXT: [[TRUNC:%[0-9]+]]:vgpr(s1) = G_TRUNC [[COPY]](s32)
184 ; GCN-NEXT: G_BRCOND [[TRUNC]](s1), %bb.1
188 liveins: $vgpr0, $vgpr1
190 %0:vgpr(s32) = COPY $vgpr0
191 %1:vgpr(s1) = G_TRUNC %0
200 name: brcond_class_intrinsic
202 regBankSelected: true
205 ; GCN-LABEL: name: brcond_class_intrinsic
207 ; GCN-NEXT: successors: %bb.1(0x80000000)
208 ; GCN-NEXT: liveins: $vgpr0, $vgpr1
210 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
211 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
212 ; GCN-NEXT: [[V_CMP_CLASS_F32_e64_:%[0-9]+]]:sreg_64 = V_CMP_CLASS_F32_e64 0, [[COPY]], [[COPY1]], implicit $exec
213 ; GCN-NEXT: $vcc = COPY [[V_CMP_CLASS_F32_e64_]]
214 ; GCN-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
218 liveins: $vgpr0, $vgpr1
220 %0:vgpr(s32) = COPY $vgpr0
221 %1:vgpr(s32) = COPY $vgpr1
222 %2:vcc(s1) = G_INTRINSIC intrinsic(@llvm.amdgcn.class), %0:vgpr(s32), %1:vgpr(s32)
223 G_BRCOND %2(s1), %bb.1
231 name: brcond_cmp_logic
233 regBankSelected: true
236 ; GCN-LABEL: name: brcond_cmp_logic
238 ; GCN-NEXT: successors: %bb.1(0x80000000)
239 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3
241 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
242 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
243 ; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
244 ; GCN-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
245 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
246 ; GCN-NEXT: [[V_CMP_EQ_F32_e64_:%[0-9]+]]:sreg_64_xexec = nofpexcept V_CMP_EQ_F32_e64 0, [[COPY2]], 0, [[COPY3]], 0, implicit $mode, implicit $exec
247 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[V_CMP_EQ_U32_e64_]], [[V_CMP_EQ_F32_e64_]], implicit-def dead $scc
248 ; GCN-NEXT: $vcc = COPY [[S_AND_B64_]]
249 ; GCN-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
253 liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3
255 %0:vgpr(s32) = COPY $vgpr0
256 %1:vgpr(s32) = COPY $vgpr1
257 %2:vgpr(s32) = COPY $vgpr2
258 %3:vgpr(s32) = COPY $vgpr3
259 %4:vcc(s1) = G_ICMP intpred(eq), %0, %1
260 %5:vcc(s1) = G_FCMP floatpred(oeq), %2, %3
261 %6:vcc(s1) = G_AND %4, %5
262 G_BRCOND %6(s1), %bb.1
272 regBankSelected: true
275 ; GCN-LABEL: name: brcond_logic
277 ; GCN-NEXT: successors: %bb.1(0x80000000)
278 ; GCN-NEXT: liveins: $sgpr0, $vgpr0, $vgpr1
280 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
281 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
282 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr0
283 ; GCN-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 1, [[COPY2]], implicit-def dead $scc
284 ; GCN-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[S_AND_B32_]], implicit $exec
285 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
286 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64_xexec = S_AND_B64 [[V_CMP_EQ_U32_e64_]], [[V_CMP_NE_U32_e64_]], implicit-def dead $scc
287 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[S_AND_B64_]], $exec, implicit-def dead $scc
288 ; GCN-NEXT: $vcc = COPY [[S_AND_B64_1]]
289 ; GCN-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
293 liveins: $sgpr0, $vgpr0, $vgpr1
295 %0:vgpr(s32) = COPY $vgpr0
296 %1:vgpr(s32) = COPY $vgpr1
297 %2:sgpr(s32) = COPY $sgpr0
298 %3:sgpr(s1) = G_TRUNC %2(s32)
299 %4:vcc(s1) = COPY %3(s1)
300 %5:vcc(s1) = G_ICMP intpred(eq), %0, %1
301 %6:vcc(s1) = G_AND %5, %4
302 G_BRCOND %6(s1), %bb.1
310 name: brcond_logic_const
312 regBankSelected: true
315 ; GCN-LABEL: name: brcond_logic_const
317 ; GCN-NEXT: successors: %bb.1(0x80000000)
318 ; GCN-NEXT: liveins: $vgpr0, $vgpr1
320 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
321 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
322 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
323 ; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 -1
324 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[V_CMP_EQ_U32_e64_]], [[S_MOV_B64_]], implicit-def dead $scc
325 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[S_XOR_B64_]], $exec, implicit-def dead $scc
326 ; GCN-NEXT: $vcc = COPY [[S_AND_B64_]]
327 ; GCN-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
331 liveins: $vgpr0, $vgpr1
333 %0:vgpr(s32) = COPY $vgpr0
334 %1:vgpr(s32) = COPY $vgpr1
335 %2:vcc(s1) = G_ICMP intpred(eq), %0, %1
336 %3:sgpr(s1) = G_CONSTANT i1 true
337 %4:vcc(s1) = COPY %3(s1)
338 %5:vcc(s1) = G_XOR %2, %4
339 G_BRCOND %5(s1), %bb.1