1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=tahiti -run-pass=instruction-select -verify-machineinstrs -global-isel %s -o - | FileCheck %s -check-prefixes=GCN
3
4---
5name:            select_s32_scc
6legalized:       true
7regBankSelected: true
8
9body: |
10  bb.0:
11    liveins:  $sgpr0, $sgpr1, $sgpr2, $sgpr3
12
13    ; GCN-LABEL: name: select_s32_scc
14    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
15    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
16    ; GCN: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
17    ; GCN: [[COPY3:%[0-9]+]]:sreg_32 = COPY $sgpr3
18    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
19    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
20    ; GCN: $scc = COPY [[COPY4]]
21    ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[COPY2]], [[COPY3]], implicit $scc
22    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
23    %0:sgpr(s32) = COPY $sgpr0
24    %1:sgpr(s32) = COPY $sgpr1
25    %2:sgpr(s32) = COPY $sgpr2
26    %3:sgpr(s32) = COPY $sgpr3
27    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
28    %5:sgpr(s32) = G_SELECT %4, %2, %3
29    S_ENDPGM 0, implicit %5
30
31...
32
33---
34name:            select_s64_scc
35legalized:       true
36regBankSelected: true
37
38body: |
39  bb.0:
40    liveins:  $sgpr0, $sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
41
42    ; GCN-LABEL: name: select_s64_scc
43    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
44    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
45    ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
46    ; GCN: [[COPY3:%[0-9]+]]:sreg_64 = COPY $sgpr4_sgpr5
47    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
48    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
49    ; GCN: $scc = COPY [[COPY4]]
50    ; GCN: [[S_CSELECT_B64_:%[0-9]+]]:sreg_64 = S_CSELECT_B64 [[COPY2]], [[COPY3]], implicit $scc
51    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B64_]]
52    %0:sgpr(s32) = COPY $sgpr0
53    %1:sgpr(s32) = COPY $sgpr1
54    %2:sgpr(s64) = COPY $sgpr2_sgpr3
55    %3:sgpr(s64) = COPY $sgpr4_sgpr5
56    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
57    %5:sgpr(s64) = G_SELECT %4, %2, %3
58    S_ENDPGM 0, implicit %5
59
60...
61
62---
63name:            select_p0_scc
64legalized:       true
65regBankSelected: true
66
67body: |
68  bb.0:
69    liveins:  $sgpr0, $sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
70
71    ; GCN-LABEL: name: select_p0_scc
72    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
73    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
74    ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
75    ; GCN: [[COPY3:%[0-9]+]]:sreg_64 = COPY $sgpr4_sgpr5
76    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
77    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
78    ; GCN: $scc = COPY [[COPY4]]
79    ; GCN: [[S_CSELECT_B64_:%[0-9]+]]:sreg_64 = S_CSELECT_B64 [[COPY2]], [[COPY3]], implicit $scc
80    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B64_]]
81    %0:sgpr(s32) = COPY $sgpr0
82    %1:sgpr(s32) = COPY $sgpr1
83    %2:sgpr(p0) = COPY $sgpr2_sgpr3
84    %3:sgpr(p0) = COPY $sgpr4_sgpr5
85    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
86    %5:sgpr(p0) = G_SELECT %4, %2, %3
87    S_ENDPGM 0, implicit %5
88
89...
90
91---
92name:            select_p1_scc
93legalized:       true
94regBankSelected: true
95
96body: |
97  bb.0:
98    liveins:  $sgpr0, $sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
99
100    ; GCN-LABEL: name: select_p1_scc
101    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
102    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
103    ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
104    ; GCN: [[COPY3:%[0-9]+]]:sreg_64 = COPY $sgpr4_sgpr5
105    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
106    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
107    ; GCN: $scc = COPY [[COPY4]]
108    ; GCN: [[S_CSELECT_B64_:%[0-9]+]]:sreg_64 = S_CSELECT_B64 [[COPY2]], [[COPY3]], implicit $scc
109    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B64_]]
110    %0:sgpr(s32) = COPY $sgpr0
111    %1:sgpr(s32) = COPY $sgpr1
112    %2:sgpr(p1) = COPY $sgpr2_sgpr3
113    %3:sgpr(p1) = COPY $sgpr4_sgpr5
114    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
115    %5:sgpr(p1) = G_SELECT %4, %2, %3
116    S_ENDPGM 0, implicit %5
117
118...
119
120---
121name:            select_p999_scc
122legalized:       true
123regBankSelected: true
124
125body: |
126  bb.0:
127    liveins:  $sgpr0, $sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
128
129    ; GCN-LABEL: name: select_p999_scc
130    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
131    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
132    ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
133    ; GCN: [[COPY3:%[0-9]+]]:sreg_64 = COPY $sgpr4_sgpr5
134    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
135    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
136    ; GCN: $scc = COPY [[COPY4]]
137    ; GCN: [[S_CSELECT_B64_:%[0-9]+]]:sreg_64 = S_CSELECT_B64 [[COPY2]], [[COPY3]], implicit $scc
138    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B64_]]
139    %0:sgpr(s32) = COPY $sgpr0
140    %1:sgpr(s32) = COPY $sgpr1
141    %2:sgpr(p999) = COPY $sgpr2_sgpr3
142    %3:sgpr(p999) = COPY $sgpr4_sgpr5
143    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
144    %5:sgpr(p999) = G_SELECT %4, %2, %3
145    S_ENDPGM 0, implicit %5
146
147...
148
149---
150name:            select_v4s16_scc
151legalized:       true
152regBankSelected: true
153
154body: |
155  bb.0:
156    liveins:  $sgpr0, $sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
157
158    ; GCN-LABEL: name: select_v4s16_scc
159    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
160    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
161    ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $sgpr2_sgpr3
162    ; GCN: [[COPY3:%[0-9]+]]:sreg_64 = COPY $sgpr4_sgpr5
163    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
164    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
165    ; GCN: $scc = COPY [[COPY4]]
166    ; GCN: [[S_CSELECT_B64_:%[0-9]+]]:sreg_64 = S_CSELECT_B64 [[COPY2]], [[COPY3]], implicit $scc
167    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B64_]]
168    %0:sgpr(s32) = COPY $sgpr0
169    %1:sgpr(s32) = COPY $sgpr1
170    %2:sgpr(<4 x s16>) = COPY $sgpr2_sgpr3
171    %3:sgpr(<4 x s16>) = COPY $sgpr4_sgpr5
172    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
173    %5:sgpr(<4 x s16>) = G_SELECT %4, %2, %3
174    S_ENDPGM 0, implicit %5
175
176...
177
178---
179name:            select_s16_scc
180legalized:       true
181regBankSelected: true
182
183body: |
184  bb.0:
185    liveins:  $sgpr0, $sgpr1, $sgpr2, $sgpr3
186
187    ; GCN-LABEL: name: select_s16_scc
188    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
189    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
190    ; GCN: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
191    ; GCN: [[COPY3:%[0-9]+]]:sreg_32 = COPY $sgpr3
192    ; GCN: S_CMP_EQ_U32 [[COPY2]], [[COPY3]], implicit-def $scc
193    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
194    ; GCN: $scc = COPY [[COPY4]]
195    ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[COPY]], [[COPY1]], implicit $scc
196    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
197    %0:sgpr(s32) = COPY $sgpr0
198    %1:sgpr(s32) = COPY $sgpr1
199    %2:sgpr(s32) = COPY $sgpr2
200    %3:sgpr(s32) = COPY $sgpr3
201    %4:sgpr(s16) = G_TRUNC %0
202    %5:sgpr(s16) = G_TRUNC %1
203    %6:sgpr(s32) = G_ICMP intpred(eq), %2, %3
204    %7:sgpr(s16) = G_SELECT %6, %4, %5
205    S_ENDPGM 0, implicit %7
206
207...
208
209---
210name:            select_v2s16_scc
211legalized:       true
212regBankSelected: true
213
214body: |
215  bb.0:
216    liveins:  $sgpr0, $sgpr1, $sgpr2, $sgpr3
217
218    ; GCN-LABEL: name: select_v2s16_scc
219    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
220    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
221    ; GCN: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
222    ; GCN: [[COPY3:%[0-9]+]]:sreg_32 = COPY $sgpr3
223    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
224    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
225    ; GCN: $scc = COPY [[COPY4]]
226    ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[COPY2]], [[COPY3]], implicit $scc
227    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
228    %0:sgpr(s32) = COPY $sgpr0
229    %1:sgpr(s32) = COPY $sgpr1
230    %2:sgpr(<2 x s16>) = COPY $sgpr2
231    %3:sgpr(<2 x s16>) = COPY $sgpr3
232    %4:sgpr(s32) = G_ICMP intpred(eq), %0, %1
233    %5:sgpr(<2 x s16>) = G_SELECT %4, %2, %3
234    S_ENDPGM 0, implicit %5
235
236...
237
238---
239name:            select_s32_vcc
240legalized:       true
241regBankSelected: true
242
243body: |
244  bb.0:
245    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
246
247    ; GCN-LABEL: name: select_s32_vcc
248    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
249    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
250    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
251    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
252    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
253    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY3]], 0, [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit $exec
254    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
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:vgpr(s32) = G_SELECT %4, %2, %3
261    S_ENDPGM 0, implicit %5
262
263...
264
265---
266name:            select_s16_vcc
267legalized:       true
268regBankSelected: true
269
270body: |
271  bb.0:
272    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
273
274    ; GCN-LABEL: name: select_s16_vcc
275    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
276    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
277    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
278    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
279    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY2]], [[COPY3]], implicit $exec
280    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY1]], 0, [[COPY]], [[V_CMP_EQ_U32_e64_]], implicit $exec
281    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
282    %0:vgpr(s32) = COPY $vgpr0
283    %1:vgpr(s32) = COPY $vgpr1
284    %2:vgpr(s32) = COPY $vgpr2
285    %3:vgpr(s32) = COPY $vgpr3
286    %4:vgpr(s16) = G_TRUNC %0
287    %5:vgpr(s16) = G_TRUNC %1
288    %6:vcc(s1) = G_ICMP intpred(eq), %2, %3
289    %7:vgpr(s16) = G_SELECT %6, %4, %5
290    S_ENDPGM 0, implicit %7
291
292...
293
294---
295name:            select_v2s16_vcc
296legalized:       true
297regBankSelected: true
298
299body: |
300  bb.0:
301    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
302
303    ; GCN-LABEL: name: select_v2s16_vcc
304    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
305    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
306    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
307    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
308    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
309    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY3]], 0, [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit $exec
310    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
311    %0:vgpr(s32) = COPY $vgpr0
312    %1:vgpr(s32) = COPY $vgpr1
313    %2:vgpr(<2 x s16>) = COPY $vgpr2
314    %3:vgpr(<2 x s16>) = COPY $vgpr3
315    %4:vcc(s1) = G_ICMP intpred(eq), %0, %1
316    %5:vgpr(<2 x s16>) = G_SELECT %4, %2, %3
317    S_ENDPGM 0, implicit %5
318
319...
320
321---
322name:            select_p3_vcc
323legalized:       true
324regBankSelected: true
325
326body: |
327  bb.0:
328    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
329
330    ; GCN-LABEL: name: select_p3_vcc
331    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
332    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
333    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
334    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
335    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
336    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY3]], 0, [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit $exec
337    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
338    %0:vgpr(s32) = COPY $vgpr0
339    %1:vgpr(s32) = COPY $vgpr1
340    %2:vgpr(p3) = COPY $vgpr2
341    %3:vgpr(p3) = COPY $vgpr3
342    %4:vcc(s1) = G_ICMP intpred(eq), %0, %1
343    %5:vgpr(p3) = G_SELECT %4, %2, %3
344    S_ENDPGM 0, implicit %5
345
346...
347
348# Fold source modifiers into VOP select
349---
350name:            select_s32_vcc_fneg_lhs
351legalized:       true
352regBankSelected: true
353
354body: |
355  bb.0:
356    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
357
358    ; GCN-LABEL: name: select_s32_vcc_fneg_lhs
359    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
360    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
361    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
362    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
363    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
364    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY3]], 1, [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit $exec
365    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
366    %0:vgpr(s32) = COPY $vgpr0
367    %1:vgpr(s32) = COPY $vgpr1
368    %2:vgpr(s32) = COPY $vgpr2
369    %3:vgpr(s32) = COPY $vgpr3
370    %4:vgpr(s32) = G_FNEG %2
371    %5:vcc(s1) = G_ICMP intpred(eq), %0, %1
372    %6:vgpr(s32) = G_SELECT %5, %4, %3
373    S_ENDPGM 0, implicit %6
374
375...
376
377---
378name:            select_s32_vcc_fneg_rhs
379legalized:       true
380regBankSelected: true
381
382body: |
383  bb.0:
384    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
385
386    ; GCN-LABEL: name: select_s32_vcc_fneg_rhs
387    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
388    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
389    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
390    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
391    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
392    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 1, [[COPY3]], 0, [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit $exec
393    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
394    %0:vgpr(s32) = COPY $vgpr0
395    %1:vgpr(s32) = COPY $vgpr1
396    %2:vgpr(s32) = COPY $vgpr2
397    %3:vgpr(s32) = COPY $vgpr3
398    %4:vgpr(s32) = G_FNEG %3
399    %5:vcc(s1) = G_ICMP intpred(eq), %0, %1
400    %6:vgpr(s32) = G_SELECT %5, %2, %4
401    S_ENDPGM 0, implicit %6
402
403...
404
405---
406name:            select_s32_vcc_fneg_fabs_lhs
407legalized:       true
408regBankSelected: true
409
410body: |
411  bb.0:
412    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
413
414    ; GCN-LABEL: name: select_s32_vcc_fneg_fabs_lhs
415    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
416    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
417    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
418    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
419    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
420    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 3, [[COPY3]], [[V_CMP_EQ_U32_e64_]], implicit $exec
421    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
422    %0:vgpr(s32) = COPY $vgpr0
423    %1:vgpr(s32) = COPY $vgpr1
424    %2:vgpr(s32) = COPY $vgpr2
425    %3:vgpr(s32) = COPY $vgpr3
426    %4:vgpr(s32) = G_FABS %3
427    %5:vgpr(s32) = G_FNEG %4
428    %6:vcc(s1) = G_ICMP intpred(eq), %0, %1
429    %7:vgpr(s32) = G_SELECT %6, %5, %2
430    S_ENDPGM 0, implicit %7
431
432...
433
434# Make sure we don't try to fold source modifiers into non-32 bit value.
435---
436name:            select_s16_vcc_fneg_lhs
437legalized:       true
438regBankSelected: true
439
440body: |
441  bb.0:
442    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
443
444    ; GCN-LABEL: name: select_s16_vcc_fneg_lhs
445    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
446    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
447    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
448    ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
449    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 32768
450    ; GCN: [[V_XOR_B32_e32_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e32 [[S_MOV_B32_]], [[COPY]], implicit $exec
451    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY2]], [[COPY3]], implicit $exec
452    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY1]], 0, [[V_XOR_B32_e32_]], [[V_CMP_EQ_U32_e64_]], implicit $exec
453    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
454    %0:vgpr(s32) = COPY $vgpr0
455    %1:vgpr(s32) = COPY $vgpr1
456    %2:vgpr(s32) = COPY $vgpr2
457    %3:vgpr(s32) = COPY $vgpr3
458    %4:vgpr(s16) = G_TRUNC %0
459    %5:vgpr(s16) = G_TRUNC %1
460    %6:vgpr(s16) = G_FNEG %4
461    %7:vcc(s1) = G_ICMP intpred(eq), %2, %3
462    %8:vgpr(s16) = G_SELECT %7, %6, %5
463    S_ENDPGM 0, implicit %8
464
465...
466
467
468# Make sure we don't try to fold source modifiers into a vector
469---
470name:            select_v2s16_vcc_fneg_lhs
471legalized:       true
472regBankSelected: true
473
474body: |
475  bb.0:
476    liveins:  $vgpr0, $vgpr1, $vgpr2, $vgpr3
477
478    ; GCN-LABEL: name: select_v2s16_vcc_fneg_lhs
479    ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
480    ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
481    ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
482    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2147516416
483    ; GCN: [[V_XOR_B32_e32_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e32 [[S_MOV_B32_]], [[COPY2]], implicit $exec
484    ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
485    ; GCN: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[V_XOR_B32_e32_]], [[V_CMP_EQ_U32_e64_]], implicit $exec
486    ; GCN: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
487    %0:vgpr(s32) = COPY $vgpr0
488    %1:vgpr(s32) = COPY $vgpr1
489    %2:vgpr(<2 x s16>) = COPY $vgpr2
490    %3:vgpr(<2 x s16>) = COPY $vgpr3
491    %4:vgpr(<2 x s16>) = G_FNEG %3
492    %5:vcc(s1) = G_ICMP intpred(eq), %0, %1
493    %6:vgpr(<2 x s16>) = G_SELECT %5, %4, %3
494    S_ENDPGM 0, implicit %6
495
496...
497
498# Make sure we don't try to fold source modifiers into a scalar select
499
500---
501name:            select_s32_scc_fneg_lhs
502legalized:       true
503regBankSelected: true
504
505body: |
506  bb.0:
507    liveins:  $sgpr0, $sgpr1, $sgpr2, $sgpr3
508
509    ; GCN-LABEL: name: select_s32_scc_fneg_lhs
510    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
511    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
512    ; GCN: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
513    ; GCN: [[COPY3:%[0-9]+]]:sreg_32 = COPY $sgpr3
514    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2147483648
515    ; GCN: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY2]], [[S_MOV_B32_]], implicit-def $scc
516    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
517    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
518    ; GCN: $scc = COPY [[COPY4]]
519    ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[S_XOR_B32_]], [[COPY3]], implicit $scc
520    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
521    %0:sgpr(s32) = COPY $sgpr0
522    %1:sgpr(s32) = COPY $sgpr1
523    %2:sgpr(s32) = COPY $sgpr2
524    %3:sgpr(s32) = COPY $sgpr3
525    %4:sgpr(s32) = G_FNEG %2
526    %5:sgpr(s32) = G_ICMP intpred(eq), %0, %1
527    %6:sgpr(s32) = G_SELECT %5, %4, %3
528    S_ENDPGM 0, implicit %6
529
530...
531
532---
533name:            select_s32_scc_fneg_rhs
534legalized:       true
535regBankSelected: true
536
537body: |
538  bb.0:
539    liveins:  $sgpr0, $sgpr1, $sgpr2, $sgpr3
540
541    ; GCN-LABEL: name: select_s32_scc_fneg_rhs
542    ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
543    ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
544    ; GCN: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
545    ; GCN: [[COPY3:%[0-9]+]]:sreg_32 = COPY $sgpr3
546    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2147483648
547    ; GCN: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY3]], [[S_MOV_B32_]], implicit-def $scc
548    ; GCN: S_CMP_EQ_U32 [[COPY]], [[COPY1]], implicit-def $scc
549    ; GCN: [[COPY4:%[0-9]+]]:sreg_32 = COPY $scc
550    ; GCN: $scc = COPY [[COPY4]]
551    ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[COPY2]], [[S_XOR_B32_]], implicit $scc
552    ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
553    %0:sgpr(s32) = COPY $sgpr0
554    %1:sgpr(s32) = COPY $sgpr1
555    %2:sgpr(s32) = COPY $sgpr2
556    %3:sgpr(s32) = COPY $sgpr3
557    %4:sgpr(s32) = G_FNEG %3
558    %5:sgpr(s32) = G_ICMP intpred(eq), %0, %1
559    %6:sgpr(s32) = G_SELECT %5, %2, %4
560    S_ENDPGM 0, implicit %6
561
562...
563