1# RUN: llc -march=amdgcn -mcpu=hawaii -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN -DVCCRC=sreg_64_xexec %s
2# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN -DVCCRC=sreg_64_xexec %s
3# RUN: llc -march=amdgcn -mcpu=gfx1010 -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN -DVCCRC=sreg_32_xm0_xexec %s
4
5---
6name:            icmp_s32_s_mix
7legalized:       true
8regBankSelected: true
9
10# GCN: name: icmp_s32_s_mix
11# GCN: [[SGPR0:%[0-9]+]]:sreg_32 = COPY $sgpr0
12# GCN: [[SGPR1:%[0-9]+]]:sreg_32 = COPY $sgpr1
13# GCN: [[SGPR2:%[0-9]+]]:sreg_32 = COPY $sgpr2
14# GCN: [[SGPR3:%[0-9]+]]:sreg_32 = COPY $sgpr3
15# GCN: [[SGPR4:%[0-9]+]]:sreg_32 = COPY $sgpr4
16# GCN: [[SGPR5:%[0-9]+]]:sreg_32 = COPY $sgpr5
17# GCN: [[SGPR6:%[0-9]+]]:sreg_32 = COPY $sgpr6
18# GCN: [[SGPR7:%[0-9]+]]:sreg_32 = COPY $sgpr7
19# GCN: S_CMP_LG_U32 [[SGPR0]], [[SGPR1]], implicit-def $scc
20# GCN-NEXT: [[COND0:%[0-9]+]]:sreg_32 = COPY $scc
21# GCN: S_CMP_LG_U32 [[SGPR4]], [[SGPR5]], implicit-def $scc
22# GCN-NEXT: [[COND1:%[0-9]+]]:sreg_32 = COPY $scc
23# GCN: $scc = COPY [[COND0]]
24# GCN-NEXT: S_CSELECT_B32 [[SGPR6]], [[SGPR7]], implicit $scc
25# GCN: $scc = COPY [[COND1]]
26# GCN-NEXT: S_CSELECT_B32 [[SGPR2]], [[SGPR3]], implicit $scc
27
28body: |
29  bb.0:
30    liveins:  $vgpr0_vgpr1, $sgpr0, $sgpr1, $sgpr2, $sgpr3, $sgpr4, $sgpr5, $sgpr6, $sgpr7
31
32    %0:vgpr(p1) = COPY $vgpr0_vgpr1
33    %1:sgpr(s32) = COPY $sgpr0
34    %2:sgpr(s32) = COPY $sgpr1
35    %3:sgpr(s32) = COPY $sgpr2
36    %4:sgpr(s32) = COPY $sgpr3
37    %5:sgpr(s32) = COPY $sgpr4
38    %6:sgpr(s32) = COPY $sgpr5
39    %7:sgpr(s32) = COPY $sgpr6
40    %8:sgpr(s32) = COPY $sgpr7
41    %9:sgpr(s32) = G_ICMP intpred(ne), %1, %2
42    %10:sgpr(s32) = G_ICMP intpred(ne), %5, %6
43    %11:sgpr(s32) = G_SELECT %9, %7, %8
44    %12:sgpr(s32) = G_SELECT %10, %3, %4
45    %13:vgpr(s32) = COPY %11
46    G_STORE %13, %0 :: (volatile store 4, addrspace 1)
47    %14:vgpr(s32) = COPY %12
48    G_STORE %14, %0 :: (volatile store 4, addrspace 1)
49
50...
51---
52name:            icmp_s32_salu
53legalized:       true
54regBankSelected: true
55
56# GCN-LABEL: name: icmp_s32_salu
57# GCN: S_CMP_LG_U32
58# GCN: S_CMP_EQ_U32
59# GCN: S_CMP_GT_I32
60# GCN: S_CMP_GE_I32
61# GCN: S_CMP_LT_I32
62# GCN: S_CMP_LE_I32
63# GCN: S_CMP_GT_U32
64# GCN: S_CMP_GE_U32
65# GCN: S_CMP_LT_U32
66# GCN: S_CMP_LE_U32
67
68body: |
69  bb.0:
70    liveins: $vgpr0_vgpr1, $sgpr0, $sgpr1, $sgpr2, $sgpr3
71
72    %0:vgpr(p1) = COPY $vgpr0_vgpr1
73    %1:sgpr(s32) = COPY $sgpr0
74    %2:sgpr(s32) = COPY $sgpr1
75    %3:sgpr(s32) = COPY $sgpr2
76    %4:sgpr(s32) = COPY $sgpr3
77    %5:sgpr(s32) = G_ICMP intpred(ne), %1, %2
78    %6:sgpr(s32) = G_ICMP intpred(eq), %1, %2
79    %7:sgpr(s32) = G_ICMP intpred(sgt), %1, %2
80    %8:sgpr(s32) = G_ICMP intpred(sge), %1, %2
81    %9:sgpr(s32) = G_ICMP intpred(slt), %1, %2
82    %10:sgpr(s32) = G_ICMP intpred(sle), %1, %2
83    %11:sgpr(s32) = G_ICMP intpred(ugt), %1, %2
84    %12:sgpr(s32) = G_ICMP intpred(uge), %1, %2
85    %13:sgpr(s32) = G_ICMP intpred(ult), %1, %2
86    %14:sgpr(s32) = G_ICMP intpred(ule), %1, %2
87    %15:sgpr(s32) = G_SELECT %5, %3, %4
88    %16:sgpr(s32) = G_SELECT %6, %3, %4
89    %17:sgpr(s32) = G_SELECT %7, %3, %4
90    %18:sgpr(s32) = G_SELECT %8, %3, %4
91    %19:sgpr(s32) = G_SELECT %9, %3, %4
92    %20:sgpr(s32) = G_SELECT %10, %3, %4
93    %21:sgpr(s32) = G_SELECT %11, %3, %4
94    %22:sgpr(s32) = G_SELECT %12, %3, %4
95    %23:sgpr(s32) = G_SELECT %13, %3, %4
96    %24:sgpr(s32) = G_SELECT %14, %3, %4
97    %25:vgpr(s32) = COPY %15
98    G_STORE %25, %0 :: (volatile store 4, addrspace 1)
99    %26:vgpr(s32) = COPY %16
100    G_STORE %26, %0 :: (volatile store 4, addrspace 1)
101    %27:vgpr(s32) = COPY %17
102    G_STORE %27, %0 :: (volatile store 4, addrspace 1)
103    %28:vgpr(s32) = COPY %18
104    G_STORE %28, %0 :: (volatile store 4, addrspace 1)
105    %29:vgpr(s32) = COPY %19
106    G_STORE %29, %0 :: (volatile store 4, addrspace 1)
107    %30:vgpr(s32) = COPY %20
108    G_STORE %30, %0 :: (volatile store 4, addrspace 1)
109    %31:vgpr(s32) = COPY %21
110    G_STORE %31, %0 :: (volatile store 4, addrspace 1)
111    %32:vgpr(s32) = COPY %22
112    G_STORE %32, %0 :: (volatile store 4, addrspace 1)
113    %33:vgpr(s32) = COPY %23
114    G_STORE %33, %0 :: (volatile store 4, addrspace 1)
115    %34:vgpr(s32) = COPY %24
116    G_STORE %34, %0 :: (volatile store 4, addrspace 1)
117
118...
119---
120name:            icmp_s32_v_mix
121legalized:       true
122regBankSelected: true
123
124# GCN-LABEL: name: icmp_s32_v_mix
125# GCN: [[VGPR2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
126# GCN: [[VGPR3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
127# GCN: [[VGPR4:%[0-9]+]]:vgpr_32 = COPY $vgpr4
128# GCN: [[VGPR5:%[0-9]+]]:vgpr_32 = COPY $vgpr5
129# GCN: [[VGPR6:%[0-9]+]]:vgpr_32 = COPY $vgpr6
130# GCN: [[VGPR7:%[0-9]+]]:vgpr_32 = COPY $vgpr7
131# GCN: [[VGPR8:%[0-9]+]]:vgpr_32 = COPY $vgpr8
132# GCN: [[VGPR9:%[0-9]+]]:vgpr_32 = COPY $vgpr9
133# GCN: [[COND0:%[0-9]+]]:[[VCCRC]] = V_CMP_NE_U32_e64 [[VGPR2]], [[VGPR3]]
134# GCN: [[COND1:%[0-9]+]]:[[VCCRC]] = V_CMP_NE_U32_e64 [[VGPR6]], [[VGPR7]]
135# GCN: V_CNDMASK_B32_e64 0, [[VGPR9]], 0, [[VGPR8]], [[COND0]]
136# GCN: V_CNDMASK_B32_e64 0, [[VGPR5]], 0, [[VGPR4]], [[COND1]]
137
138body: |
139  bb.0:
140    liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7, $vgpr8, $vgpr9
141
142    %0:vgpr(p1) = COPY $vgpr0_vgpr1
143    %1:vgpr(s32) = COPY $vgpr2
144    %2:vgpr(s32) = COPY $vgpr3
145    %3:vgpr(s32) = COPY $vgpr4
146    %4:vgpr(s32) = COPY $vgpr5
147    %5:vgpr(s32) = COPY $vgpr6
148    %6:vgpr(s32) = COPY $vgpr7
149    %7:vgpr(s32) = COPY $vgpr8
150    %8:vgpr(s32) = COPY $vgpr9
151    %9:vcc(s1) = G_ICMP intpred(ne), %1, %2
152    %10:vcc(s1) = G_ICMP intpred(ne), %5, %6
153    %11:vgpr(s32) = G_SELECT %9, %7, %8
154    %12:vgpr(s32) = G_SELECT %10, %3, %4
155    G_STORE %11, %0 :: (volatile store 4, addrspace 1)
156    G_STORE %12, %0 :: (volatile store 4, addrspace 1)
157...
158---
159name:            icmp_s32_valu
160legalized:       true
161regBankSelected: true
162
163# GCN-LABEL: name: icmp_s32_valu
164# GCN: V_CMP_NE_U32_e64
165# GCN: V_CMP_EQ_U32_e64
166# GCN: V_CMP_GT_I32_e64
167# GCN: V_CMP_GE_I32_e64
168# GCN: V_CMP_LT_I32_e64
169# GCN: V_CMP_LE_I32_e64
170# GCN: V_CMP_GT_U32_e64
171# GCN: V_CMP_GE_U32_e64
172# GCN: V_CMP_LT_U32_e64
173# GCN: V_CMP_LE_U32_e64
174
175body: |
176  bb.0:
177    liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5
178
179    %0:vgpr(p1) = COPY $vgpr0_vgpr1
180    %1:vgpr(s32) = COPY $vgpr2
181    %2:vgpr(s32) = COPY $vgpr3
182    %3:vgpr(s32) = COPY $vgpr4
183    %4:vgpr(s32) = COPY $vgpr5
184    %5:vcc(s1) = G_ICMP intpred(ne), %1, %2
185    %6:vcc(s1) = G_ICMP intpred(eq), %1, %2
186    %7:vcc(s1) = G_ICMP intpred(sgt), %1, %2
187    %8:vcc(s1) = G_ICMP intpred(sge), %1, %2
188    %9:vcc(s1) = G_ICMP intpred(slt), %1, %2
189    %10:vcc(s1) = G_ICMP intpred(sle), %1, %2
190    %11:vcc(s1) = G_ICMP intpred(ugt), %1, %2
191    %12:vcc(s1) = G_ICMP intpred(uge), %1, %2
192    %13:vcc(s1) = G_ICMP intpred(ult), %1, %2
193    %14:vcc(s1) = G_ICMP intpred(ule), %1, %2
194    %15:vgpr(s32) = G_SELECT %5, %3, %4
195    %16:vgpr(s32) = G_SELECT %6, %3, %4
196    %17:vgpr(s32) = G_SELECT %7, %3, %4
197    %18:vgpr(s32) = G_SELECT %8, %3, %4
198    %19:vgpr(s32) = G_SELECT %9, %3, %4
199    %20:vgpr(s32) = G_SELECT %10, %3, %4
200    %21:vgpr(s32) = G_SELECT %11, %3, %4
201    %22:vgpr(s32) = G_SELECT %12, %3, %4
202    %23:vgpr(s32) = G_SELECT %13, %3, %4
203    %24:vgpr(s32) = G_SELECT %14, %3, %4
204    G_STORE %15, %0 :: (volatile store 4, addrspace 1)
205    G_STORE %16, %0 :: (volatile store 4, addrspace 1)
206    G_STORE %17, %0 :: (volatile store 4, addrspace 1)
207    G_STORE %18, %0 :: (volatile store 4, addrspace 1)
208    G_STORE %19, %0 :: (volatile store 4, addrspace 1)
209    G_STORE %20, %0 :: (volatile store 4, addrspace 1)
210    G_STORE %21, %0 :: (volatile store 4, addrspace 1)
211    G_STORE %22, %0 :: (volatile store 4, addrspace 1)
212    G_STORE %23, %0 :: (volatile store 4, addrspace 1)
213    G_STORE %24, %0 :: (volatile store 4, addrspace 1)
214...
215---
216
217name:            icmp_s32_vv
218legalized:       true
219regBankSelected: true
220
221# GCN-LABEL: name: icmp_s32_vv
222# GCN: [[VGPR2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
223# GCN: [[VGPR3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
224# GCN: V_CMP_NE_U32_e64 [[VGPR2]], [[VGPR3]]
225
226body: |
227  bb.0:
228    liveins:  $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5
229
230    %0:vgpr(p1) = COPY $vgpr0_vgpr1
231    %1:vgpr(s32) = COPY $vgpr2
232    %2:vgpr(s32) = COPY $vgpr3
233    %3:vgpr(s32) = COPY $vgpr4
234    %4:vgpr(s32) = COPY $vgpr5
235    %5:vcc(s1) = G_ICMP intpred(ne), %1, %2
236    %6:vgpr(s32) = G_SELECT %5, %3, %4
237    G_STORE %6, %0 :: (store 4, addrspace 1)
238...
239---
240
241name:            icmp_s32_vs
242legalized:       true
243regBankSelected: true
244
245# GCN-LABEL: name: icmp_s32_vs
246# GCN: [[VGPR2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
247# GCN: [[SGPR0:%[0-9]+]]:sreg_32 = COPY $sgpr0
248# GCN: V_CMP_NE_U32_e64 [[VGPR2]], [[SGPR0]]
249
250body: |
251  bb.0:
252    liveins:  $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $sgpr0
253
254    %0:vgpr(p1) = COPY $vgpr0_vgpr1
255    %1:vgpr(s32) = COPY $vgpr2
256    %2:vgpr(s32) = COPY $vgpr3
257    %3:vgpr(s32) = COPY $vgpr4
258    %4:sgpr(s32) = COPY $sgpr0
259    %5:vcc(s1) = G_ICMP intpred(ne), %1, %4
260    %6:vgpr(s32) = G_SELECT %5, %2, %3
261    G_STORE %6, %0 :: (store 4, addrspace 1)
262...
263---
264
265name:            icmp_s32_sv
266legalized:       true
267regBankSelected: true
268
269# GCN-LABEL: name: icmp_s32_sv
270# GCN: [[VGPR2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
271# GCN: [[SGPR0:%[0-9]+]]:sreg_32 = COPY $sgpr0
272# GCN: V_CMP_NE_U32_e64 [[SGPR0]], [[VGPR2]]
273
274body: |
275  bb.0:
276    liveins:  $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $sgpr0
277
278    %0:vgpr(p1) = COPY $vgpr0_vgpr1
279    %1:vgpr(s32) = COPY $vgpr2
280    %2:vgpr(s32) = COPY $vgpr3
281    %3:vgpr(s32) = COPY $vgpr4
282    %4:sgpr(s32) = COPY $sgpr0
283    %5:vcc(s1) = G_ICMP intpred(ne), %4, %1
284    %6:vgpr(s32) = G_SELECT %5, %2, %3
285    G_STORE %6, %0 :: (store 4, addrspace 1)
286...
287---
288
289name:            icmp_s32_or_vcc
290legalized:       true
291regBankSelected: true
292
293# GCN-LABEL: name: icmp_s32_or_vcc
294# GCN: [[VGPR2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
295# GCN: [[SGPR0:%[0-9]+]]:sreg_32 = COPY $sgpr0
296# GCN: V_CMP_NE_U32_e64 [[SGPR0]], [[VGPR2]]
297
298body: |
299  bb.0:
300    liveins:  $vgpr0_vgpr1, $vgpr2, $vgpr3, $vgpr4, $sgpr0
301
302    %0:vgpr(p1) = COPY $vgpr0_vgpr1
303    %1:vgpr(s32) = COPY $vgpr2
304    %2:vgpr(s32) = COPY $vgpr3
305    %3:vgpr(s32) = COPY $vgpr4
306    %4:sgpr(s32) = COPY $sgpr0
307    %5:vcc(s1) = G_ICMP intpred(ne), %4, %1
308    %6:vgpr(s32) = G_SELECT %5, %2, %3
309    G_STORE %6, %0 :: (store 4, addrspace 1)
310...
311
312---
313
314name:            icmp_eq_ne_p3_ss
315legalized:       true
316regBankSelected: true
317
318# GCN-LABEL: name: icmp_eq_ne_p3_ss
319# GCN: S_CMP_EQ_U32 %0, %1, implicit-def $scc
320# GCN: S_CMP_LG_U32 %0, %1, implicit-def $scc
321
322body: |
323  bb.0:
324    liveins:  $sgpr0, $sgpr1
325
326    %0:sgpr(p3) = COPY $sgpr0
327    %1:sgpr(p3) = COPY $sgpr1
328    %2:sgpr(s32) = G_ICMP intpred(eq), %0, %1
329    %3:sgpr(s32) = G_ICMP intpred(ne), %0, %1
330    S_ENDPGM 0, implicit %2, implicit %3
331
332...
333
334---
335
336name:            icmp_eq_ne_p3_vv
337legalized:       true
338regBankSelected: true
339
340# GCN-LABEL: name: icmp_eq_ne_p3_vv
341# GCN: %2:[[VCCRC]] = V_CMP_EQ_U32_e64 %0, %1, implicit $exec
342# GCN: %3:[[VCCRC]] = V_CMP_NE_U32_e64 %0, %1, implicit $exec
343
344body: |
345  bb.0:
346    liveins:  $vgpr0, $vgpr1
347
348    %0:vgpr(p3) = COPY $vgpr0
349    %1:vgpr(p3) = COPY $vgpr1
350    %2:vcc(s1) = G_ICMP intpred(eq), %0, %1
351    %3:vcc(s1) = G_ICMP intpred(ne), %0, %1
352    %4:vgpr(s1) = COPY %2
353    %5:vgpr(s1) = COPY %3
354    %6:vgpr(s32) = G_SEXT %4
355    %7:vgpr(s32) = G_SEXT %5
356    S_ENDPGM 0, implicit %6, implicit %7
357
358...
359