1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-prelegalizer-combiner -simplify-mir -verify-machineinstrs -o - %s | FileCheck %s
5 name: no_fold_add_into_select_s32_0_multi_use
6 tracksRegLiveness: true
10 ; CHECK-LABEL: name: no_fold_add_into_select_s32_0_multi_use
11 ; CHECK: liveins: $vgpr0
13 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
14 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
15 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
16 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
17 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
18 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
19 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
20 ; CHECK-NEXT: %add:_(s32) = G_ADD %select, %thirty
21 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32), implicit %select(s32)
22 %reg:_(s32) = COPY $vgpr0
23 %zero:_(s32) = G_CONSTANT i32 0
24 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
25 %ten:_(s32) = G_CONSTANT i32 10
26 %twenty:_(s32) = G_CONSTANT i32 20
27 %select:_(s32) = G_SELECT %cond, %ten, %twenty
28 %thirty:_(s32) = G_CONSTANT i32 30
29 %add:_(s32) = G_ADD %select, %thirty
30 S_ENDPGM 0, implicit %add, implicit %select
34 name: no_fold_add_into_select_s32_1_multi_use
35 tracksRegLiveness: true
39 ; CHECK-LABEL: name: no_fold_add_into_select_s32_1_multi_use
40 ; CHECK: liveins: $vgpr0
42 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
43 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
44 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
45 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
46 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
47 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
48 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
49 ; CHECK-NEXT: %add:_(s32) = G_ADD %select, %thirty
50 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32), implicit %select(s32)
51 %reg:_(s32) = COPY $vgpr0
52 %zero:_(s32) = G_CONSTANT i32 0
53 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
54 %ten:_(s32) = G_CONSTANT i32 10
55 %twenty:_(s32) = G_CONSTANT i32 20
56 %select:_(s32) = G_SELECT %cond, %ten, %twenty
57 %thirty:_(s32) = G_CONSTANT i32 30
58 %add:_(s32) = G_ADD %thirty, %select
59 S_ENDPGM 0, implicit %add, implicit %select
63 name: no_fold_sub_into_select_s32_nonconst_rhs
64 tracksRegLiveness: true
67 liveins: $vgpr0, $vgpr1
68 ; CHECK-LABEL: name: no_fold_sub_into_select_s32_nonconst_rhs
69 ; CHECK: liveins: $vgpr0, $vgpr1
71 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
72 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
73 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
74 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
75 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
76 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
77 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
78 ; CHECK-NEXT: %sub:_(s32) = G_SUB %select, %variable
79 ; CHECK-NEXT: S_ENDPGM 0, implicit %sub(s32)
80 %reg:_(s32) = COPY $vgpr0
81 %variable:_(s32) = COPY $vgpr0
82 %zero:_(s32) = G_CONSTANT i32 0
83 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
84 %ten:_(s32) = G_CONSTANT i32 10
85 %twenty:_(s32) = G_CONSTANT i32 20
86 %select:_(s32) = G_SELECT %cond, %ten, %twenty
87 %thirty:_(s32) = G_CONSTANT i32 30
88 %sub:_(s32) = G_SUB %select, %variable
89 S_ENDPGM 0, implicit %sub
93 name: no_fold_sub_into_select_s32_nonconst_lhs
94 tracksRegLiveness: true
97 liveins: $vgpr0, $vgpr1
98 ; CHECK-LABEL: name: no_fold_sub_into_select_s32_nonconst_lhs
99 ; CHECK: liveins: $vgpr0, $vgpr1
101 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
102 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
103 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
104 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
105 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
106 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
107 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
108 ; CHECK-NEXT: %sub:_(s32) = G_SUB %variable, %select
109 ; CHECK-NEXT: S_ENDPGM 0, implicit %sub(s32)
110 %reg:_(s32) = COPY $vgpr0
111 %variable:_(s32) = COPY $vgpr0
112 %zero:_(s32) = G_CONSTANT i32 0
113 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
114 %ten:_(s32) = G_CONSTANT i32 10
115 %twenty:_(s32) = G_CONSTANT i32 20
116 %select:_(s32) = G_SELECT %cond, %ten, %twenty
117 %thirty:_(s32) = G_CONSTANT i32 30
118 %sub:_(s32) = G_SUB %variable, %select
119 S_ENDPGM 0, implicit %sub
123 name: fold_add_into_select_s32_0
124 tracksRegLiveness: true
128 ; CHECK-LABEL: name: fold_add_into_select_s32_0
129 ; CHECK: liveins: $vgpr0
131 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
132 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
133 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
134 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
135 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
136 ; CHECK-NEXT: %add:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
137 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32)
138 %reg:_(s32) = COPY $vgpr0
139 %zero:_(s32) = G_CONSTANT i32 0
140 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
141 %ten:_(s32) = G_CONSTANT i32 10
142 %twenty:_(s32) = G_CONSTANT i32 20
143 %select:_(s32) = G_SELECT %cond, %ten, %twenty
144 %thirty:_(s32) = G_CONSTANT i32 30
145 %add:_(s32) = G_ADD %select, %thirty
146 S_ENDPGM 0, implicit %add
150 name: fold_add_into_select_s32_1
151 tracksRegLiveness: true
155 ; CHECK-LABEL: name: fold_add_into_select_s32_1
156 ; CHECK: liveins: $vgpr0
158 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
159 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
160 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
161 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
162 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
163 ; CHECK-NEXT: %add:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
164 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32)
165 %reg:_(s32) = COPY $vgpr0
166 %zero:_(s32) = G_CONSTANT i32 0
167 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
168 %ten:_(s32) = G_CONSTANT i32 10
169 %twenty:_(s32) = G_CONSTANT i32 20
170 %select:_(s32) = G_SELECT %cond, %ten, %twenty
171 %thirty:_(s32) = G_CONSTANT i32 30
172 %add:_(s32) = G_ADD %thirty, %select
173 S_ENDPGM 0, implicit %add
177 name: fold_add_into_select_v2s32_splat
178 tracksRegLiveness: true
181 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
182 ; CHECK-LABEL: name: fold_add_into_select_v2s32_splat
183 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
185 ; CHECK-NEXT: %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
186 ; CHECK-NEXT: %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
187 ; CHECK-NEXT: %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0(<2 x s32>), %reg1
188 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
189 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32)
190 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
191 ; CHECK-NEXT: [[BUILD_VECTOR1:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C1]](s32), [[C1]](s32)
192 ; CHECK-NEXT: %add:_(<2 x s32>) = G_SELECT %cond(<2 x s1>), [[BUILD_VECTOR]], [[BUILD_VECTOR1]]
193 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(<2 x s32>)
194 %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
195 %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
196 %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0, %reg1
197 %ten:_(s32) = G_CONSTANT i32 10
198 %twenty:_(s32) = G_CONSTANT i32 20
199 %ten_vec:_(<2 x s32>) = G_BUILD_VECTOR %ten, %ten
200 %twenty_vec:_(<2 x s32>) = G_BUILD_VECTOR %twenty, %twenty
201 %select:_(<2 x s32>) = G_SELECT %cond, %ten_vec, %twenty_vec
202 %thirty:_(s32) = G_CONSTANT i32 30
203 %thirty_vec:_(<2 x s32>) = G_BUILD_VECTOR %thirty, %thirty
204 %add:_(<2 x s32>) = G_ADD %select, %thirty_vec
205 S_ENDPGM 0, implicit %add
209 name: fold_add_into_select_v2s32_nonsplat
210 tracksRegLiveness: true
213 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
214 ; CHECK-LABEL: name: fold_add_into_select_v2s32_nonsplat
215 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
217 ; CHECK-NEXT: %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
218 ; CHECK-NEXT: %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
219 ; CHECK-NEXT: %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0(<2 x s32>), %reg1
220 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
221 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
222 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
223 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), %thirty(s32)
224 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
225 ; CHECK-NEXT: [[BUILD_VECTOR1:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C1]](s32), %twenty(s32)
226 ; CHECK-NEXT: %add:_(<2 x s32>) = G_SELECT %cond(<2 x s1>), [[BUILD_VECTOR]], [[BUILD_VECTOR1]]
227 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(<2 x s32>)
228 %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
229 %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
230 %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0, %reg1
231 %ten:_(s32) = G_CONSTANT i32 10
232 %twenty:_(s32) = G_CONSTANT i32 20
233 %const_vec0:_(<2 x s32>) = G_BUILD_VECTOR %ten, %twenty
234 %const_vec1:_(<2 x s32>) = G_BUILD_VECTOR %twenty, %ten
235 %select:_(<2 x s32>) = G_SELECT %cond, %const_vec0, %const_vec1
236 %thirty:_(s32) = G_CONSTANT i32 30
237 %const_vec3:_(<2 x s32>) = G_BUILD_VECTOR %thirty, %ten
238 %add:_(<2 x s32>) = G_ADD %select, %const_vec3
239 S_ENDPGM 0, implicit %add
243 name: fold_add_into_select_v2s32_nonsplat_undef
244 tracksRegLiveness: true
247 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
248 ; CHECK-LABEL: name: fold_add_into_select_v2s32_nonsplat_undef
249 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
251 ; CHECK-NEXT: %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
252 ; CHECK-NEXT: %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
253 ; CHECK-NEXT: %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0(<2 x s32>), %reg1
254 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
255 ; CHECK-NEXT: %undef:_(s32) = G_IMPLICIT_DEF
256 ; CHECK-NEXT: %const_vec0:_(<2 x s32>) = G_BUILD_VECTOR %undef(s32), %twenty(s32)
257 ; CHECK-NEXT: %const_vec1:_(<2 x s32>) = G_BUILD_VECTOR %twenty(s32), %undef(s32)
258 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
259 ; CHECK-NEXT: %const_vec3:_(<2 x s32>) = G_BUILD_VECTOR %thirty(s32), %undef(s32)
260 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(<2 x s32>) = G_ADD %const_vec0, %const_vec3
261 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(<2 x s32>) = G_ADD %const_vec1, %const_vec3
262 ; CHECK-NEXT: %add:_(<2 x s32>) = G_SELECT %cond(<2 x s1>), [[ADD]], [[ADD1]]
263 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(<2 x s32>)
264 %reg0:_(<2 x s32>) = COPY $vgpr0_vgpr1
265 %reg1:_(<2 x s32>) = COPY $vgpr2_vgpr3
266 %cond:_(<2 x s1>) = G_ICMP intpred(eq), %reg0, %reg1
267 %ten:_(s32) = G_CONSTANT i32 10
268 %twenty:_(s32) = G_CONSTANT i32 20
269 %undef:_(s32) = G_IMPLICIT_DEF
270 %const_vec0:_(<2 x s32>) = G_BUILD_VECTOR %undef, %twenty
271 %const_vec1:_(<2 x s32>) = G_BUILD_VECTOR %twenty, %undef
272 %select:_(<2 x s32>) = G_SELECT %cond, %const_vec0, %const_vec1
273 %thirty:_(s32) = G_CONSTANT i32 30
274 %const_vec3:_(<2 x s32>) = G_BUILD_VECTOR %thirty, %undef
275 %add:_(<2 x s32>) = G_ADD %select, %const_vec3
276 S_ENDPGM 0, implicit %add
280 name: fold_sub_into_select_s32_0
281 tracksRegLiveness: true
285 ; CHECK-LABEL: name: fold_sub_into_select_s32_0
286 ; CHECK: liveins: $vgpr0
288 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
289 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
290 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
291 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -20
292 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -10
293 ; CHECK-NEXT: %sub:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
294 ; CHECK-NEXT: S_ENDPGM 0, implicit %sub(s32)
295 %reg:_(s32) = COPY $vgpr0
296 %zero:_(s32) = G_CONSTANT i32 0
297 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
298 %ten:_(s32) = G_CONSTANT i32 10
299 %twenty:_(s32) = G_CONSTANT i32 20
300 %select:_(s32) = G_SELECT %cond, %ten, %twenty
301 %thirty:_(s32) = G_CONSTANT i32 30
302 %sub:_(s32) = G_SUB %select, %thirty
303 S_ENDPGM 0, implicit %sub
307 name: fold_sub_into_select_s32_1
308 tracksRegLiveness: true
312 ; CHECK-LABEL: name: fold_sub_into_select_s32_1
313 ; CHECK: liveins: $vgpr0
315 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
316 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
317 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
318 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
319 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
320 ; CHECK-NEXT: %sub:_(s32) = G_SELECT %cond(s1), %twenty, %ten
321 ; CHECK-NEXT: S_ENDPGM 0, implicit %sub(s32)
322 %reg:_(s32) = COPY $vgpr0
323 %zero:_(s32) = G_CONSTANT i32 0
324 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
325 %ten:_(s32) = G_CONSTANT i32 10
326 %twenty:_(s32) = G_CONSTANT i32 20
327 %select:_(s32) = G_SELECT %cond, %ten, %twenty
328 %thirty:_(s32) = G_CONSTANT i32 30
329 %sub:_(s32) = G_SUB %thirty, %select
330 S_ENDPGM 0, implicit %sub
334 name: fold_ptr_add_into_select_p3_0
335 tracksRegLiveness: true
339 ; CHECK-LABEL: name: fold_ptr_add_into_select_p3_0
340 ; CHECK: liveins: $vgpr0
342 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
343 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
344 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
345 ; CHECK-NEXT: [[C:%[0-9]+]]:_(p3) = G_CONSTANT i32 40
346 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(p3) = G_CONSTANT i32 50
347 ; CHECK-NEXT: %ptr_add:_(p3) = G_SELECT %cond(s1), [[C]], [[C1]]
348 ; CHECK-NEXT: S_ENDPGM 0, implicit %ptr_add(p3)
349 %reg:_(s32) = COPY $vgpr0
350 %zero:_(s32) = G_CONSTANT i32 0
351 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
352 %ten:_(p3) = G_CONSTANT i32 10
353 %twenty:_(p3) = G_CONSTANT i32 20
354 %select:_(p3) = G_SELECT %cond, %ten, %twenty
355 %thirty:_(s32) = G_CONSTANT i32 30
356 %ptr_add:_(p3) = G_PTR_ADD %select, %thirty
357 S_ENDPGM 0, implicit %ptr_add
361 name: fold_ptr_add_into_select_p3_1
362 tracksRegLiveness: true
366 ; CHECK-LABEL: name: fold_ptr_add_into_select_p3_1
367 ; CHECK: liveins: $vgpr0
369 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
370 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
371 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
372 ; CHECK-NEXT: [[C:%[0-9]+]]:_(p3) = G_CONSTANT i32 40
373 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(p3) = G_CONSTANT i32 50
374 ; CHECK-NEXT: %ptr_add:_(p3) = G_SELECT %cond(s1), [[C]], [[C1]]
375 ; CHECK-NEXT: S_ENDPGM 0, implicit %ptr_add(p3)
376 %reg:_(s32) = COPY $vgpr0
377 %zero:_(s32) = G_CONSTANT i32 0
378 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
379 %ten:_(s32) = G_CONSTANT i32 10
380 %twenty:_(s32) = G_CONSTANT i32 20
381 %select:_(s32) = G_SELECT %cond, %ten, %twenty
382 %thirty:_(p3) = G_CONSTANT i32 30
383 %ptr_add:_(p3) = G_PTR_ADD %thirty, %select
384 S_ENDPGM 0, implicit %ptr_add
388 name: fold_shl_into_select_s64_0
389 tracksRegLiveness: true
393 ; CHECK-LABEL: name: fold_shl_into_select_s64_0
394 ; CHECK: liveins: $vgpr0
396 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
397 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
398 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
399 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1280
400 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2560
401 ; CHECK-NEXT: %shl:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
402 ; CHECK-NEXT: S_ENDPGM 0, implicit %shl(s64)
403 %reg:_(s32) = COPY $vgpr0
404 %zero:_(s32) = G_CONSTANT i32 0
405 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
406 %ten:_(s64) = G_CONSTANT i64 10
407 %twenty:_(s64) = G_CONSTANT i64 20
408 %select:_(s64) = G_SELECT %cond, %ten, %twenty
409 %seven:_(s32) = G_CONSTANT i32 7
410 %shl:_(s64) = G_SHL %select, %seven
411 S_ENDPGM 0, implicit %shl
415 name: fold_shl_into_select_s64_1
416 tracksRegLiveness: true
420 ; CHECK-LABEL: name: fold_shl_into_select_s64_1
421 ; CHECK: liveins: $vgpr0
423 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
424 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
425 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
426 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8192
427 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 524288
428 ; CHECK-NEXT: %shl:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
429 ; CHECK-NEXT: S_ENDPGM 0, implicit %shl(s64)
430 %reg:_(s32) = COPY $vgpr0
431 %zero:_(s32) = G_CONSTANT i32 0
432 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
433 %ten:_(s32) = G_CONSTANT i32 10
434 %sixteen:_(s32) = G_CONSTANT i32 16
435 %select:_(s32) = G_SELECT %cond, %ten, %sixteen
436 %eight:_(s64) = G_CONSTANT i64 8
437 %shl:_(s64) = G_SHL %eight, %select
438 S_ENDPGM 0, implicit %shl
442 name: fold_and_variable_into_select_zero_neg1_s32
443 tracksRegLiveness: true
446 liveins: $vgpr0, $vgpr1
447 ; CHECK-LABEL: name: fold_and_variable_into_select_zero_neg1_s32
448 ; CHECK: liveins: $vgpr0, $vgpr1
450 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
451 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
452 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
453 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
454 ; CHECK-NEXT: %and:_(s32) = G_SELECT %cond(s1), %zero, %variable
455 ; CHECK-NEXT: S_ENDPGM 0, implicit %and(s32)
456 %reg:_(s32) = COPY $vgpr0
457 %variable:_(s32) = COPY $vgpr0
458 %zero:_(s32) = G_CONSTANT i32 0
459 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
460 %neg1:_(s32) = G_CONSTANT i32 -1
461 %select:_(s32) = G_SELECT %cond, %zero, %neg1
462 %and:_(s32) = G_AND %select, %variable
463 S_ENDPGM 0, implicit %and
467 name: fold_and_variable_into_select_neg1_zero_s32
468 tracksRegLiveness: true
471 liveins: $vgpr0, $vgpr1
472 ; CHECK-LABEL: name: fold_and_variable_into_select_neg1_zero_s32
473 ; CHECK: liveins: $vgpr0, $vgpr1
475 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
476 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
477 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
478 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
479 ; CHECK-NEXT: %and:_(s32) = G_SELECT %cond(s1), %variable, %zero
480 ; CHECK-NEXT: S_ENDPGM 0, implicit %and(s32)
481 %reg:_(s32) = COPY $vgpr0
482 %variable:_(s32) = COPY $vgpr0
483 %zero:_(s32) = G_CONSTANT i32 0
484 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
485 %neg1:_(s32) = G_CONSTANT i32 -1
486 %select:_(s32) = G_SELECT %cond, %neg1, %zero
487 %and:_(s32) = G_AND %select, %variable
488 S_ENDPGM 0, implicit %and
492 name: fold_or_variable_into_select_zero_neg1_s32
493 tracksRegLiveness: true
496 liveins: $vgpr0, $vgpr1
497 ; CHECK-LABEL: name: fold_or_variable_into_select_zero_neg1_s32
498 ; CHECK: liveins: $vgpr0, $vgpr1
500 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
501 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
502 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
503 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
504 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
505 ; CHECK-NEXT: %or:_(s32) = G_SELECT %cond(s1), %variable, %neg1
506 ; CHECK-NEXT: S_ENDPGM 0, implicit %or(s32)
507 %reg:_(s32) = COPY $vgpr0
508 %variable:_(s32) = COPY $vgpr0
509 %zero:_(s32) = G_CONSTANT i32 0
510 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
511 %neg1:_(s32) = G_CONSTANT i32 -1
512 %select:_(s32) = G_SELECT %cond, %zero, %neg1
513 %or:_(s32) = G_OR %select, %variable
514 S_ENDPGM 0, implicit %or
518 name: fold_or_variable_into_select_neg1_zero_s32
519 tracksRegLiveness: true
522 liveins: $vgpr0, $vgpr1
523 ; CHECK-LABEL: name: fold_or_variable_into_select_neg1_zero_s32
524 ; CHECK: liveins: $vgpr0, $vgpr1
526 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
527 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
528 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
529 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
530 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
531 ; CHECK-NEXT: %or:_(s32) = G_SELECT %cond(s1), %neg1, %variable
532 ; CHECK-NEXT: S_ENDPGM 0, implicit %or(s32)
533 %reg:_(s32) = COPY $vgpr0
534 %variable:_(s32) = COPY $vgpr0
535 %zero:_(s32) = G_CONSTANT i32 0
536 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
537 %neg1:_(s32) = G_CONSTANT i32 -1
538 %select:_(s32) = G_SELECT %cond, %neg1, %zero
539 %or:_(s32) = G_OR %select, %variable
540 S_ENDPGM 0, implicit %or
544 name: fold_and_variable_into_select_undef_neg1_s32
545 tracksRegLiveness: true
548 liveins: $vgpr0, $vgpr1
549 ; CHECK-LABEL: name: fold_and_variable_into_select_undef_neg1_s32
550 ; CHECK: liveins: $vgpr0, $vgpr1
552 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
553 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
554 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
555 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
556 ; CHECK-NEXT: %undef:_(s32) = G_IMPLICIT_DEF
557 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
558 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %undef, %neg1
559 ; CHECK-NEXT: %and:_(s32) = G_AND %select, %variable
560 ; CHECK-NEXT: S_ENDPGM 0, implicit %and(s32)
561 %reg:_(s32) = COPY $vgpr0
562 %variable:_(s32) = COPY $vgpr0
563 %zero:_(s32) = G_CONSTANT i32 0
564 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
565 %undef:_(s32) = G_IMPLICIT_DEF
566 %neg1:_(s32) = G_CONSTANT i32 -1
567 %select:_(s32) = G_SELECT %cond, %undef, %neg1
568 %and:_(s32) = G_AND %select, %variable
569 S_ENDPGM 0, implicit %and
573 name: fold_and_variable_into_select_undef_zero_s32
574 tracksRegLiveness: true
577 liveins: $vgpr0, $vgpr1
578 ; CHECK-LABEL: name: fold_and_variable_into_select_undef_zero_s32
579 ; CHECK: liveins: $vgpr0, $vgpr1
581 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
582 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
583 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
584 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
585 ; CHECK-NEXT: %undef:_(s32) = G_IMPLICIT_DEF
586 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %undef, %zero
587 ; CHECK-NEXT: %and:_(s32) = G_AND %select, %variable
588 ; CHECK-NEXT: S_ENDPGM 0, implicit %and(s32)
589 %reg:_(s32) = COPY $vgpr0
590 %variable:_(s32) = COPY $vgpr0
591 %zero:_(s32) = G_CONSTANT i32 0
592 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
593 %undef:_(s32) = G_IMPLICIT_DEF
594 %select:_(s32) = G_SELECT %cond, %undef, %zero
595 %and:_(s32) = G_AND %select, %variable
596 S_ENDPGM 0, implicit %and
600 name: fold_or_variable_into_select_neg1_fpzero_s32
601 tracksRegLiveness: true
604 liveins: $vgpr0, $vgpr1
605 ; CHECK-LABEL: name: fold_or_variable_into_select_neg1_fpzero_s32
606 ; CHECK: liveins: $vgpr0, $vgpr1
608 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
609 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
610 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
611 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
612 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
613 ; CHECK-NEXT: %fpzero:_(s32) = G_FCONSTANT float 0.000000e+00
614 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR %fpzero, %variable
615 ; CHECK-NEXT: %or:_(s32) = G_SELECT %cond(s1), %neg1, [[OR]]
616 ; CHECK-NEXT: S_ENDPGM 0, implicit %or(s32)
617 %reg:_(s32) = COPY $vgpr0
618 %variable:_(s32) = COPY $vgpr0
619 %zero:_(s32) = G_CONSTANT i32 0
620 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
621 %neg1:_(s32) = G_CONSTANT i32 -1
622 %fpzero:_(s32) = G_FCONSTANT float 0.0
623 %select:_(s32) = G_SELECT %cond, %neg1, %fpzero
624 %or:_(s32) = G_OR %select, %variable
625 S_ENDPGM 0, implicit %or
629 name: no_fold_or_variable_into_select_neg1_fpnegzero_s32
630 tracksRegLiveness: true
633 liveins: $vgpr0, $vgpr1
634 ; CHECK-LABEL: name: no_fold_or_variable_into_select_neg1_fpnegzero_s32
635 ; CHECK: liveins: $vgpr0, $vgpr1
637 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
638 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
639 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
640 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
641 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
642 ; CHECK-NEXT: %fpzero:_(s32) = G_FCONSTANT float -0.000000e+00
643 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %neg1, %fpzero
644 ; CHECK-NEXT: %or:_(s32) = G_OR %select, %variable
645 ; CHECK-NEXT: S_ENDPGM 0, implicit %or(s32)
646 %reg:_(s32) = COPY $vgpr0
647 %variable:_(s32) = COPY $vgpr0
648 %zero:_(s32) = G_CONSTANT i32 0
649 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
650 %neg1:_(s32) = G_CONSTANT i32 -1
651 %fpzero:_(s32) = G_FCONSTANT float -0.0
652 %select:_(s32) = G_SELECT %cond, %neg1, %fpzero
653 %or:_(s32) = G_OR %select, %variable
654 S_ENDPGM 0, implicit %or
658 name: no_fold_or_variable_into_select_neg1_other_const_s32
659 tracksRegLiveness: true
662 liveins: $vgpr0, $vgpr1
663 ; CHECK-LABEL: name: no_fold_or_variable_into_select_neg1_other_const_s32
664 ; CHECK: liveins: $vgpr0, $vgpr1
666 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
667 ; CHECK-NEXT: %variable:_(s32) = COPY $vgpr0
668 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
669 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
670 ; CHECK-NEXT: %neg1:_(s32) = G_CONSTANT i32 -1
671 ; CHECK-NEXT: %otherconst:_(s32) = G_CONSTANT i32 123
672 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %neg1, %otherconst
673 ; CHECK-NEXT: %or:_(s32) = G_OR %select, %variable
674 ; CHECK-NEXT: S_ENDPGM 0, implicit %or(s32)
675 %reg:_(s32) = COPY $vgpr0
676 %variable:_(s32) = COPY $vgpr0
677 %zero:_(s32) = G_CONSTANT i32 0
678 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
679 %neg1:_(s32) = G_CONSTANT i32 -1
680 %otherconst:_(s32) = G_CONSTANT i32 123
681 %select:_(s32) = G_SELECT %cond, %neg1, %otherconst
682 %or:_(s32) = G_OR %select, %variable
683 S_ENDPGM 0, implicit %or
687 name: fold_xor_into_select_s32_0
688 tracksRegLiveness: true
692 ; CHECK-LABEL: name: fold_xor_into_select_s32_0
693 ; CHECK: liveins: $vgpr0
695 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
696 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
697 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
698 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
699 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
700 ; CHECK-NEXT: %xor:_(s32) = G_SELECT %cond(s1), %twenty, %ten
701 ; CHECK-NEXT: S_ENDPGM 0, implicit %xor(s32)
702 %reg:_(s32) = COPY $vgpr0
703 %zero:_(s32) = G_CONSTANT i32 0
704 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
705 %ten:_(s32) = G_CONSTANT i32 10
706 %twenty:_(s32) = G_CONSTANT i32 20
707 %select:_(s32) = G_SELECT %cond, %ten, %twenty
708 %thirty:_(s32) = G_CONSTANT i32 30
709 %xor:_(s32) = G_XOR %select, %thirty
710 S_ENDPGM 0, implicit %xor
714 name: fold_sdiv_into_select_s32_0
715 tracksRegLiveness: true
719 ; CHECK-LABEL: name: fold_sdiv_into_select_s32_0
720 ; CHECK: liveins: $vgpr0
722 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
723 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
724 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
725 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
726 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 21
727 ; CHECK-NEXT: %sdiv:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
728 ; CHECK-NEXT: S_ENDPGM 0, implicit %sdiv(s32)
729 %reg:_(s32) = COPY $vgpr0
730 %zero:_(s32) = G_CONSTANT i32 0
731 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
732 %hundred:_(s32) = G_CONSTANT i32 100
733 %fortytwo:_(s32) = G_CONSTANT i32 42
734 %select:_(s32) = G_SELECT %cond, %hundred, %fortytwo
735 %two:_(s32) = G_CONSTANT i32 2
736 %sdiv:_(s32) = G_SDIV %select, %two
737 S_ENDPGM 0, implicit %sdiv
741 name: fold_srem_into_select_s32_0
742 tracksRegLiveness: true
746 ; CHECK-LABEL: name: fold_srem_into_select_s32_0
747 ; CHECK: liveins: $vgpr0
749 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
750 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
751 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
752 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
753 ; CHECK-NEXT: %srem:_(s32) = G_SELECT %cond(s1), [[C]], %zero
754 ; CHECK-NEXT: S_ENDPGM 0, implicit %srem(s32)
755 %reg:_(s32) = COPY $vgpr0
756 %zero:_(s32) = G_CONSTANT i32 0
757 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
758 %hundred:_(s32) = G_CONSTANT i32 100
759 %fortytwo:_(s32) = G_CONSTANT i32 42
760 %select:_(s32) = G_SELECT %cond, %hundred, %fortytwo
761 %three:_(s32) = G_CONSTANT i32 3
762 %srem:_(s32) = G_SREM %select, %three
763 S_ENDPGM 0, implicit %srem
767 name: fold_udiv_into_select_s32_0
768 tracksRegLiveness: true
772 ; CHECK-LABEL: name: fold_udiv_into_select_s32_0
773 ; CHECK: liveins: $vgpr0
775 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
776 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
777 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
778 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
779 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 21
780 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
781 ; CHECK-NEXT: S_ENDPGM 0, implicit [[SELECT]](s32)
782 %reg:_(s32) = COPY $vgpr0
783 %zero:_(s32) = G_CONSTANT i32 0
784 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
785 %hundred:_(s32) = G_CONSTANT i32 100
786 %fortytwo:_(s32) = G_CONSTANT i32 42
787 %select:_(s32) = G_SELECT %cond, %hundred, %fortytwo
788 %two:_(s32) = G_CONSTANT i32 2
789 %udiv:_(s32) = G_UDIV %select, %two
790 S_ENDPGM 0, implicit %udiv
794 name: fold_urem_into_select_s32_0
795 tracksRegLiveness: true
799 ; CHECK-LABEL: name: fold_urem_into_select_s32_0
800 ; CHECK: liveins: $vgpr0
802 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
803 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
804 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
805 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
806 ; CHECK-NEXT: %udiv:_(s32) = G_SELECT %cond(s1), [[C]], %zero
807 ; CHECK-NEXT: S_ENDPGM 0, implicit %udiv(s32)
808 %reg:_(s32) = COPY $vgpr0
809 %zero:_(s32) = G_CONSTANT i32 0
810 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
811 %hundred:_(s32) = G_CONSTANT i32 100
812 %fortytwo:_(s32) = G_CONSTANT i32 42
813 %select:_(s32) = G_SELECT %cond, %hundred, %fortytwo
814 %three:_(s32) = G_CONSTANT i32 3
815 %udiv:_(s32) = G_UREM %select, %three
816 S_ENDPGM 0, implicit %udiv
820 name: fold_lshr_into_select_s64_0
821 tracksRegLiveness: true
825 ; CHECK-LABEL: name: fold_lshr_into_select_s64_0
826 ; CHECK: liveins: $vgpr0
828 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
829 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
830 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
831 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
832 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 5
833 ; CHECK-NEXT: %lshr:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
834 ; CHECK-NEXT: S_ENDPGM 0, implicit %lshr(s64)
835 %reg:_(s32) = COPY $vgpr0
836 %zero:_(s32) = G_CONSTANT i32 0
837 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
838 %ten:_(s64) = G_CONSTANT i64 10
839 %twenty:_(s64) = G_CONSTANT i64 20
840 %select:_(s64) = G_SELECT %cond, %ten, %twenty
841 %two:_(s32) = G_CONSTANT i32 2
842 %lshr:_(s64) = G_LSHR %select, %two
843 S_ENDPGM 0, implicit %lshr
847 name: fold_lshr_into_select_s64_1
848 tracksRegLiveness: true
852 ; CHECK-LABEL: name: fold_lshr_into_select_s64_1
853 ; CHECK: liveins: $vgpr0
855 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
856 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
857 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
858 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1012
859 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 253
860 ; CHECK-NEXT: %lshr:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
861 ; CHECK-NEXT: S_ENDPGM 0, implicit %lshr(s64)
862 %reg:_(s32) = COPY $vgpr0
863 %zero:_(s32) = G_CONSTANT i32 0
864 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
865 %three:_(s32) = G_CONSTANT i32 3
866 %five:_(s32) = G_CONSTANT i32 5
867 %select:_(s32) = G_SELECT %cond, %three, %five
868 %val:_(s64) = G_CONSTANT i64 8096
869 %lshr:_(s64) = G_LSHR %val, %select
870 S_ENDPGM 0, implicit %lshr
874 name: fold_ashr_into_select_s64_0
875 tracksRegLiveness: true
879 ; CHECK-LABEL: name: fold_ashr_into_select_s64_0
880 ; CHECK: liveins: $vgpr0
882 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
883 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
884 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
885 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
886 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 5
887 ; CHECK-NEXT: %ashr:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
888 ; CHECK-NEXT: S_ENDPGM 0, implicit %ashr(s64)
889 %reg:_(s32) = COPY $vgpr0
890 %zero:_(s32) = G_CONSTANT i32 0
891 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
892 %ten:_(s64) = G_CONSTANT i64 10
893 %twenty:_(s64) = G_CONSTANT i64 20
894 %select:_(s64) = G_SELECT %cond, %ten, %twenty
895 %two:_(s32) = G_CONSTANT i32 2
896 %ashr:_(s64) = G_ASHR %select, %two
897 S_ENDPGM 0, implicit %ashr
901 name: fold_ashr_into_select_s64_1
902 tracksRegLiveness: true
906 ; CHECK-LABEL: name: fold_ashr_into_select_s64_1
907 ; CHECK: liveins: $vgpr0
909 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
910 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
911 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
912 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1012
913 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -253
914 ; CHECK-NEXT: %ashr:_(s64) = G_SELECT %cond(s1), [[C]], [[C1]]
915 ; CHECK-NEXT: S_ENDPGM 0, implicit %ashr(s64)
916 %reg:_(s32) = COPY $vgpr0
917 %zero:_(s32) = G_CONSTANT i32 0
918 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
919 %three:_(s32) = G_CONSTANT i32 3
920 %five:_(s32) = G_CONSTANT i32 5
921 %select:_(s32) = G_SELECT %cond, %three, %five
922 %val:_(s64) = G_CONSTANT i64 -8096
923 %ashr:_(s64) = G_ASHR %val, %select
924 S_ENDPGM 0, implicit %ashr
928 name: fold_smin_into_select_s32_0
929 tracksRegLiveness: true
933 ; CHECK-LABEL: name: fold_smin_into_select_s32_0
934 ; CHECK: liveins: $vgpr0
936 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
937 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
938 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
939 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
940 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
941 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
942 ; CHECK-NEXT: S_ENDPGM 0, implicit %select(s32)
943 %reg:_(s32) = COPY $vgpr0
944 %zero:_(s32) = G_CONSTANT i32 0
945 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
946 %ten:_(s32) = G_CONSTANT i32 10
947 %twenty:_(s32) = G_CONSTANT i32 20
948 %select:_(s32) = G_SELECT %cond, %ten, %twenty
949 %thirty:_(s32) = G_CONSTANT i32 30
950 %smin:_(s32) = G_SMIN %select, %thirty
951 S_ENDPGM 0, implicit %smin
955 name: fold_smax_into_select_s32_0
956 tracksRegLiveness: true
960 ; CHECK-LABEL: name: fold_smax_into_select_s32_0
961 ; CHECK: liveins: $vgpr0
963 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
964 ; CHECK-NEXT: S_ENDPGM 0, implicit %thirty(s32)
965 %reg:_(s32) = COPY $vgpr0
966 %zero:_(s32) = G_CONSTANT i32 0
967 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
968 %ten:_(s32) = G_CONSTANT i32 10
969 %twenty:_(s32) = G_CONSTANT i32 20
970 %select:_(s32) = G_SELECT %cond, %ten, %twenty
971 %thirty:_(s32) = G_CONSTANT i32 30
972 %smax:_(s32) = G_SMAX %select, %thirty
973 S_ENDPGM 0, implicit %smax
977 name: fold_umin_into_select_s32_0
978 tracksRegLiveness: true
982 ; CHECK-LABEL: name: fold_umin_into_select_s32_0
983 ; CHECK: liveins: $vgpr0
985 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
986 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
987 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
988 ; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
989 ; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
990 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
991 ; CHECK-NEXT: S_ENDPGM 0, implicit %select(s32)
992 %reg:_(s32) = COPY $vgpr0
993 %zero:_(s32) = G_CONSTANT i32 0
994 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
995 %ten:_(s32) = G_CONSTANT i32 10
996 %twenty:_(s32) = G_CONSTANT i32 20
997 %select:_(s32) = G_SELECT %cond, %ten, %twenty
998 %thirty:_(s32) = G_CONSTANT i32 30
999 %umin:_(s32) = G_UMIN %select, %thirty
1000 S_ENDPGM 0, implicit %umin
1004 name: fold_umax_into_select_s32_0
1005 tracksRegLiveness: true
1009 ; CHECK-LABEL: name: fold_umax_into_select_s32_0
1010 ; CHECK: liveins: $vgpr0
1011 ; CHECK-NEXT: {{ $}}
1012 ; CHECK-NEXT: %thirty:_(s32) = G_CONSTANT i32 30
1013 ; CHECK-NEXT: S_ENDPGM 0, implicit %thirty(s32)
1014 %reg:_(s32) = COPY $vgpr0
1015 %zero:_(s32) = G_CONSTANT i32 0
1016 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1017 %ten:_(s32) = G_CONSTANT i32 10
1018 %twenty:_(s32) = G_CONSTANT i32 20
1019 %select:_(s32) = G_SELECT %cond, %ten, %twenty
1020 %thirty:_(s32) = G_CONSTANT i32 30
1021 %umax:_(s32) = G_UMAX %select, %thirty
1022 S_ENDPGM 0, implicit %umax
1026 name: fold_fadd_into_select_s32_0
1027 tracksRegLiveness: true
1031 ; CHECK-LABEL: name: fold_fadd_into_select_s32_0
1032 ; CHECK: liveins: $vgpr0
1033 ; CHECK-NEXT: {{ $}}
1034 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1035 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1036 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1037 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.800000e+01
1038 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float 2.000000e+01
1039 ; CHECK-NEXT: %fadd:_(s32) = nnan G_SELECT %cond(s1), [[C]], [[C1]]
1040 ; CHECK-NEXT: S_ENDPGM 0, implicit %fadd(s32)
1041 %reg:_(s32) = COPY $vgpr0
1042 %zero:_(s32) = G_CONSTANT i32 0
1043 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1044 %two:_(s32) = G_FCONSTANT float 2.0
1045 %four:_(s32) = G_FCONSTANT float 4.0
1046 %select:_(s32) = G_SELECT %cond, %two, %four
1047 %sixteen:_(s32) = G_FCONSTANT float 16.0
1048 %fadd:_(s32) = nnan G_FADD %select, %sixteen
1049 S_ENDPGM 0, implicit %fadd
1053 name: fold_fadd_into_select_s32_1
1054 tracksRegLiveness: true
1058 ; CHECK-LABEL: name: fold_fadd_into_select_s32_1
1059 ; CHECK: liveins: $vgpr0
1060 ; CHECK-NEXT: {{ $}}
1061 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1062 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1063 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1064 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.800000e+01
1065 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float 2.000000e+01
1066 ; CHECK-NEXT: %fadd:_(s32) = nnan G_SELECT %cond(s1), [[C]], [[C1]]
1067 ; CHECK-NEXT: S_ENDPGM 0, implicit %fadd(s32)
1068 %reg:_(s32) = COPY $vgpr0
1069 %zero:_(s32) = G_CONSTANT i32 0
1070 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1071 %two:_(s32) = G_FCONSTANT float 2.0
1072 %four:_(s32) = G_FCONSTANT float 4.0
1073 %select:_(s32) = G_SELECT %cond, %two, %four
1074 %sixteen:_(s32) = G_FCONSTANT float 16.0
1075 %fadd:_(s32) = nnan G_FADD %sixteen, %select
1076 S_ENDPGM 0, implicit %fadd
1080 name: fold_fsub_into_select_s32_0
1081 tracksRegLiveness: true
1085 ; CHECK-LABEL: name: fold_fsub_into_select_s32_0
1086 ; CHECK: liveins: $vgpr0
1087 ; CHECK-NEXT: {{ $}}
1088 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1089 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1090 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1091 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float -1.400000e+01
1092 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float -1.200000e+01
1093 ; CHECK-NEXT: %fsub:_(s32) = nnan G_SELECT %cond(s1), [[C]], [[C1]]
1094 ; CHECK-NEXT: S_ENDPGM 0, implicit %fsub(s32)
1095 %reg:_(s32) = COPY $vgpr0
1096 %zero:_(s32) = G_CONSTANT i32 0
1097 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1098 %two:_(s32) = G_FCONSTANT float 2.0
1099 %four:_(s32) = G_FCONSTANT float 4.0
1100 %select:_(s32) = G_SELECT %cond, %two, %four
1101 %sixteen:_(s32) = G_FCONSTANT float 16.0
1102 %fsub:_(s32) = nnan G_FSUB %select, %sixteen
1103 S_ENDPGM 0, implicit %fsub
1107 name: fold_fmul_into_select_s32_0
1108 tracksRegLiveness: true
1112 ; CHECK-LABEL: name: fold_fmul_into_select_s32_0
1113 ; CHECK: liveins: $vgpr0
1114 ; CHECK-NEXT: {{ $}}
1115 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1116 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1117 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1118 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 3.200000e+01
1119 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float 6.400000e+01
1120 ; CHECK-NEXT: %fmul:_(s32) = nnan G_SELECT %cond(s1), [[C]], [[C1]]
1121 ; CHECK-NEXT: S_ENDPGM 0, implicit %fmul(s32)
1122 %reg:_(s32) = COPY $vgpr0
1123 %zero:_(s32) = G_CONSTANT i32 0
1124 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1125 %two:_(s32) = G_FCONSTANT float 2.0
1126 %four:_(s32) = G_FCONSTANT float 4.0
1127 %select:_(s32) = G_SELECT %cond, %two, %four
1128 %sixteen:_(s32) = G_FCONSTANT float 16.0
1129 %fmul:_(s32) = nnan G_FMUL %select, %sixteen
1130 S_ENDPGM 0, implicit %fmul
1134 name: fold_fdiv_into_select_s32_0
1135 tracksRegLiveness: true
1139 ; CHECK-LABEL: name: fold_fdiv_into_select_s32_0
1140 ; CHECK: liveins: $vgpr0
1141 ; CHECK-NEXT: {{ $}}
1142 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1143 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1144 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1145 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.250000e-01
1146 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float 2.500000e-01
1147 ; CHECK-NEXT: %fdiv:_(s32) = nnan G_SELECT %cond(s1), [[C]], [[C1]]
1148 ; CHECK-NEXT: S_ENDPGM 0, implicit %fdiv(s32)
1149 %reg:_(s32) = COPY $vgpr0
1150 %zero:_(s32) = G_CONSTANT i32 0
1151 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1152 %two:_(s32) = G_FCONSTANT float 2.0
1153 %four:_(s32) = G_FCONSTANT float 4.0
1154 %select:_(s32) = G_SELECT %cond, %two, %four
1155 %sixteen:_(s32) = G_FCONSTANT float 16.0
1156 %fdiv:_(s32) = nnan G_FDIV %select, %sixteen
1157 S_ENDPGM 0, implicit %fdiv
1161 name: fold_frem_into_select_s32_0
1162 tracksRegLiveness: true
1166 ; CHECK-LABEL: name: fold_frem_into_select_s32_0
1167 ; CHECK: liveins: $vgpr0
1168 ; CHECK-NEXT: {{ $}}
1169 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1170 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1171 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1172 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1173 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1174 ; CHECK-NEXT: %frem:_(s32) = nnan G_SELECT %cond(s1), %two, %four
1175 ; CHECK-NEXT: S_ENDPGM 0, implicit %frem(s32)
1176 %reg:_(s32) = COPY $vgpr0
1177 %zero:_(s32) = G_CONSTANT i32 0
1178 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1179 %two:_(s32) = G_FCONSTANT float 2.0
1180 %four:_(s32) = G_FCONSTANT float 4.0
1181 %select:_(s32) = G_SELECT %cond, %two, %four
1182 %sixteen:_(s32) = G_FCONSTANT float 16.0
1183 %frem:_(s32) = nnan G_FREM %select, %sixteen
1184 S_ENDPGM 0, implicit %frem
1188 name: fold_fpow_into_select_s32_0
1189 tracksRegLiveness: true
1193 ; CHECK-LABEL: name: fold_fpow_into_select_s32_0
1194 ; CHECK: liveins: $vgpr0
1195 ; CHECK-NEXT: {{ $}}
1196 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1197 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1198 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1199 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1200 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1201 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %two, %four
1202 ; CHECK-NEXT: %sixteen:_(s32) = G_FCONSTANT float 1.600000e+01
1203 ; CHECK-NEXT: %fpow:_(s32) = nnan G_FPOW %select, %sixteen
1204 ; CHECK-NEXT: S_ENDPGM 0, implicit %fpow(s32)
1205 %reg:_(s32) = COPY $vgpr0
1206 %zero:_(s32) = G_CONSTANT i32 0
1207 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1208 %two:_(s32) = G_FCONSTANT float 2.0
1209 %four:_(s32) = G_FCONSTANT float 4.0
1210 %select:_(s32) = G_SELECT %cond, %two, %four
1211 %sixteen:_(s32) = G_FCONSTANT float 16.0
1212 %fpow:_(s32) = nnan G_FPOW %select, %sixteen
1213 S_ENDPGM 0, implicit %fpow
1217 name: fold_fminnum_into_select_s32_0
1218 tracksRegLiveness: true
1222 ; CHECK-LABEL: name: fold_fminnum_into_select_s32_0
1223 ; CHECK: liveins: $vgpr0
1224 ; CHECK-NEXT: {{ $}}
1225 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1226 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1227 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1228 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1229 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1230 ; CHECK-NEXT: %fminnum:_(s32) = nnan G_SELECT %cond(s1), %two, %four
1231 ; CHECK-NEXT: S_ENDPGM 0, implicit %fminnum(s32)
1232 %reg:_(s32) = COPY $vgpr0
1233 %zero:_(s32) = G_CONSTANT i32 0
1234 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1235 %two:_(s32) = G_FCONSTANT float 2.0
1236 %four:_(s32) = G_FCONSTANT float 4.0
1237 %select:_(s32) = G_SELECT %cond, %two, %four
1238 %sixteen:_(s32) = G_FCONSTANT float 16.0
1239 %fminnum:_(s32) = nnan G_FMINNUM %select, %sixteen
1240 S_ENDPGM 0, implicit %fminnum
1244 name: fold_fminnum_ieee_into_select_s32_0
1245 tracksRegLiveness: true
1249 ; CHECK-LABEL: name: fold_fminnum_ieee_into_select_s32_0
1250 ; CHECK: liveins: $vgpr0
1251 ; CHECK-NEXT: {{ $}}
1252 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1253 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1254 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1255 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1256 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1257 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %two, %four
1258 ; CHECK-NEXT: %sixteen:_(s32) = G_FCONSTANT float 1.600000e+01
1259 ; CHECK-NEXT: %fminnum_ieee:_(s32) = nnan G_FMINNUM_IEEE %select, %sixteen
1260 ; CHECK-NEXT: S_ENDPGM 0, implicit %fminnum_ieee(s32)
1261 %reg:_(s32) = COPY $vgpr0
1262 %zero:_(s32) = G_CONSTANT i32 0
1263 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1264 %two:_(s32) = G_FCONSTANT float 2.0
1265 %four:_(s32) = G_FCONSTANT float 4.0
1266 %select:_(s32) = G_SELECT %cond, %two, %four
1267 %sixteen:_(s32) = G_FCONSTANT float 16.0
1268 %fminnum_ieee:_(s32) = nnan G_FMINNUM_IEEE %select, %sixteen
1269 S_ENDPGM 0, implicit %fminnum_ieee
1273 name: fold_fmaxnum_into_select_s32_0
1274 tracksRegLiveness: true
1278 ; CHECK-LABEL: name: fold_fmaxnum_into_select_s32_0
1279 ; CHECK: liveins: $vgpr0
1280 ; CHECK-NEXT: {{ $}}
1281 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1282 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1283 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1284 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1285 ; CHECK-NEXT: %three:_(s32) = G_FCONSTANT float 3.000000e+00
1286 ; CHECK-NEXT: %fmaxnum:_(s32) = nnan G_SELECT %cond(s1), %three, %four
1287 ; CHECK-NEXT: S_ENDPGM 0, implicit %fmaxnum(s32)
1288 %reg:_(s32) = COPY $vgpr0
1289 %zero:_(s32) = G_CONSTANT i32 0
1290 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1291 %two:_(s32) = G_FCONSTANT float 2.0
1292 %four:_(s32) = G_FCONSTANT float 4.0
1293 %select:_(s32) = G_SELECT %cond, %two, %four
1294 %three:_(s32) = G_FCONSTANT float 3.0
1295 %fmaxnum:_(s32) = nnan G_FMAXNUM %select, %three
1296 S_ENDPGM 0, implicit %fmaxnum
1300 name: fold_fmaxnum_ieee_into_select_s32_0
1301 tracksRegLiveness: true
1305 ; CHECK-LABEL: name: fold_fmaxnum_ieee_into_select_s32_0
1306 ; CHECK: liveins: $vgpr0
1307 ; CHECK-NEXT: {{ $}}
1308 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1309 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1310 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1311 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1312 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1313 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %two, %four
1314 ; CHECK-NEXT: %three:_(s32) = G_FCONSTANT float 3.000000e+00
1315 ; CHECK-NEXT: %fmaxnum_ieee:_(s32) = nnan G_FMAXNUM_IEEE %select, %three
1316 ; CHECK-NEXT: S_ENDPGM 0, implicit %fmaxnum_ieee(s32)
1317 %reg:_(s32) = COPY $vgpr0
1318 %zero:_(s32) = G_CONSTANT i32 0
1319 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1320 %two:_(s32) = G_FCONSTANT float 2.0
1321 %four:_(s32) = G_FCONSTANT float 4.0
1322 %select:_(s32) = G_SELECT %cond, %two, %four
1323 %three:_(s32) = G_FCONSTANT float 3.0
1324 %fmaxnum_ieee:_(s32) = nnan G_FMAXNUM_IEEE %select, %three
1325 S_ENDPGM 0, implicit %fmaxnum_ieee
1329 name: fold_fminimum_into_select_s32_0
1330 tracksRegLiveness: true
1334 ; CHECK-LABEL: name: fold_fminimum_into_select_s32_0
1335 ; CHECK: liveins: $vgpr0
1336 ; CHECK-NEXT: {{ $}}
1337 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1338 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1339 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1340 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1341 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1342 ; CHECK-NEXT: %fminimum:_(s32) = nnan G_SELECT %cond(s1), %two, %four
1343 ; CHECK-NEXT: S_ENDPGM 0, implicit %fminimum(s32)
1344 %reg:_(s32) = COPY $vgpr0
1345 %zero:_(s32) = G_CONSTANT i32 0
1346 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1347 %two:_(s32) = G_FCONSTANT float 2.0
1348 %four:_(s32) = G_FCONSTANT float 4.0
1349 %select:_(s32) = G_SELECT %cond, %two, %four
1350 %sixteen:_(s32) = G_FCONSTANT float 16.0
1351 %fminimum:_(s32) = nnan G_FMINIMUM %select, %sixteen
1352 S_ENDPGM 0, implicit %fminimum
1356 name: fold_fmaximum_into_select_s32_0
1357 tracksRegLiveness: true
1361 ; CHECK-LABEL: name: fold_fmaximum_into_select_s32_0
1362 ; CHECK: liveins: $vgpr0
1363 ; CHECK-NEXT: {{ $}}
1364 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1365 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1366 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1367 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1368 ; CHECK-NEXT: %three:_(s32) = G_FCONSTANT float 3.000000e+00
1369 ; CHECK-NEXT: %fmaximum:_(s32) = nnan G_SELECT %cond(s1), %three, %four
1370 ; CHECK-NEXT: S_ENDPGM 0, implicit %fmaximum(s32)
1371 %reg:_(s32) = COPY $vgpr0
1372 %zero:_(s32) = G_CONSTANT i32 0
1373 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1374 %two:_(s32) = G_FCONSTANT float 2.0
1375 %four:_(s32) = G_FCONSTANT float 4.0
1376 %select:_(s32) = G_SELECT %cond, %two, %four
1377 %three:_(s32) = G_FCONSTANT float 3.0
1378 %fmaximum:_(s32) = nnan G_FMAXIMUM %select, %three
1379 S_ENDPGM 0, implicit %fmaximum
1383 name: fold_fcopysign_into_select_s32_0
1384 tracksRegLiveness: true
1388 ; CHECK-LABEL: name: fold_fcopysign_into_select_s32_0
1389 ; CHECK: liveins: $vgpr0
1390 ; CHECK-NEXT: {{ $}}
1391 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1392 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1393 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1394 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1395 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1396 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %two, %four
1397 ; CHECK-NEXT: %sixteen:_(s32) = G_FCONSTANT float 1.600000e+01
1398 ; CHECK-NEXT: %fcopysign:_(s32) = nnan G_FCOPYSIGN %select, %sixteen(s32)
1399 ; CHECK-NEXT: S_ENDPGM 0, implicit %fcopysign(s32)
1400 %reg:_(s32) = COPY $vgpr0
1401 %zero:_(s32) = G_CONSTANT i32 0
1402 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1403 %two:_(s32) = G_FCONSTANT float 2.0
1404 %four:_(s32) = G_FCONSTANT float 4.0
1405 %select:_(s32) = G_SELECT %cond, %two, %four
1406 %sixteen:_(s32) = G_FCONSTANT float 16.0
1407 %fcopysign:_(s32) = nnan G_FCOPYSIGN %select, %sixteen
1408 S_ENDPGM 0, implicit %fcopysign
1412 name: fold_fcopysign_into_select_s32_s64_0
1413 tracksRegLiveness: true
1417 ; CHECK-LABEL: name: fold_fcopysign_into_select_s32_s64_0
1418 ; CHECK: liveins: $vgpr0
1419 ; CHECK-NEXT: {{ $}}
1420 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1421 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1422 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1423 ; CHECK-NEXT: %two:_(s32) = G_FCONSTANT float 2.000000e+00
1424 ; CHECK-NEXT: %four:_(s32) = G_FCONSTANT float 4.000000e+00
1425 ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %two, %four
1426 ; CHECK-NEXT: %sixteen:_(s64) = G_FCONSTANT double 1.600000e+01
1427 ; CHECK-NEXT: %fcopysign:_(s32) = nnan G_FCOPYSIGN %select, %sixteen(s64)
1428 ; CHECK-NEXT: S_ENDPGM 0, implicit %fcopysign(s32)
1429 %reg:_(s32) = COPY $vgpr0
1430 %zero:_(s32) = G_CONSTANT i32 0
1431 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1432 %two:_(s32) = G_FCONSTANT float 2.0
1433 %four:_(s32) = G_FCONSTANT float 4.0
1434 %select:_(s32) = G_SELECT %cond, %two, %four
1435 %sixteen:_(s64) = G_FCONSTANT double 16.0
1436 %fcopysign:_(s32) = nnan G_FCOPYSIGN %select, %sixteen
1437 S_ENDPGM 0, implicit %fcopysign
1441 name: fold_fcopysign_into_select_s64_s32_0
1442 tracksRegLiveness: true
1446 ; CHECK-LABEL: name: fold_fcopysign_into_select_s64_s32_0
1447 ; CHECK: liveins: $vgpr0
1448 ; CHECK-NEXT: {{ $}}
1449 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1450 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1451 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1452 ; CHECK-NEXT: %two:_(s64) = G_FCONSTANT double 2.000000e+00
1453 ; CHECK-NEXT: %four:_(s64) = G_FCONSTANT double 4.000000e+00
1454 ; CHECK-NEXT: %select:_(s64) = G_SELECT %cond(s1), %two, %four
1455 ; CHECK-NEXT: %sixteen:_(s32) = G_FCONSTANT float 1.600000e+01
1456 ; CHECK-NEXT: %fcopysign:_(s64) = nnan G_FCOPYSIGN %select, %sixteen(s32)
1457 ; CHECK-NEXT: S_ENDPGM 0, implicit %fcopysign(s64)
1458 %reg:_(s32) = COPY $vgpr0
1459 %zero:_(s32) = G_CONSTANT i32 0
1460 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1461 %two:_(s64) = G_FCONSTANT double 2.0
1462 %four:_(s64) = G_FCONSTANT double 4.0
1463 %select:_(s64) = G_SELECT %cond, %two, %four
1464 %sixteen:_(s32) = G_FCONSTANT float 16.0
1465 %fcopysign:_(s64) = nnan G_FCOPYSIGN %select, %sixteen
1466 S_ENDPGM 0, implicit %fcopysign
1469 # Test handling of intermediate copy between add and select.
1471 name: fold_add_copy_into_select_s32_0
1472 tracksRegLiveness: true
1476 ; CHECK-LABEL: name: fold_add_copy_into_select_s32_0
1477 ; CHECK: liveins: $vgpr0
1478 ; CHECK-NEXT: {{ $}}
1479 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1480 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1481 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1482 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
1483 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
1484 ; CHECK-NEXT: %add:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
1485 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32)
1486 %reg:_(s32) = COPY $vgpr0
1487 %zero:_(s32) = G_CONSTANT i32 0
1488 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1489 %ten:_(s32) = G_CONSTANT i32 10
1490 %twenty:_(s32) = G_CONSTANT i32 20
1491 %select:_(s32) = G_SELECT %cond, %ten, %twenty
1492 %thirty:_(s32) = G_CONSTANT i32 30
1493 %copy_select:_(s32) = COPY %select
1494 %add:_(s32) = G_ADD %copy_select, %thirty
1495 S_ENDPGM 0, implicit %add
1499 name: fold_add_copy_into_select_s32_1
1500 tracksRegLiveness: true
1504 ; CHECK-LABEL: name: fold_add_copy_into_select_s32_1
1505 ; CHECK: liveins: $vgpr0
1506 ; CHECK-NEXT: {{ $}}
1507 ; CHECK-NEXT: %reg:_(s32) = COPY $vgpr0
1508 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
1509 ; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
1510 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 40
1511 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 50
1512 ; CHECK-NEXT: %add:_(s32) = G_SELECT %cond(s1), [[C]], [[C1]]
1513 ; CHECK-NEXT: S_ENDPGM 0, implicit %add(s32)
1514 %reg:_(s32) = COPY $vgpr0
1515 %zero:_(s32) = G_CONSTANT i32 0
1516 %cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
1517 %ten:_(s32) = G_CONSTANT i32 10
1518 %twenty:_(s32) = G_CONSTANT i32 20
1519 %select:_(s32) = G_SELECT %cond, %ten, %twenty
1520 %thirty:_(s32) = G_CONSTANT i32 30
1521 %copy_select:_(s32) = COPY %select
1522 %add:_(s32) = G_ADD %thirty, %copy_select
1523 S_ENDPGM 0, implicit %add