1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 ; --------------------------------------------------------------------
6 ; --------------------------------------------------------------------
8 declare float @llvm.amdgcn.rcp.f32(float) nounwind readnone
9 declare double @llvm.amdgcn.rcp.f64(double) nounwind readnone
11 define float @test_constant_fold_rcp_f32_undef() nounwind {
12 ; CHECK-LABEL: @test_constant_fold_rcp_f32_undef(
13 ; CHECK-NEXT: ret float undef
15 %val = call float @llvm.amdgcn.rcp.f32(float undef) nounwind readnone
19 define float @test_constant_fold_rcp_f32_1() nounwind {
20 ; CHECK-LABEL: @test_constant_fold_rcp_f32_1(
21 ; CHECK-NEXT: ret float 1.000000e+00
23 %val = call float @llvm.amdgcn.rcp.f32(float 1.0) nounwind readnone
27 define double @test_constant_fold_rcp_f64_1() nounwind {
28 ; CHECK-LABEL: @test_constant_fold_rcp_f64_1(
29 ; CHECK-NEXT: ret double 1.000000e+00
31 %val = call double @llvm.amdgcn.rcp.f64(double 1.0) nounwind readnone
35 define float @test_constant_fold_rcp_f32_half() nounwind {
36 ; CHECK-LABEL: @test_constant_fold_rcp_f32_half(
37 ; CHECK-NEXT: ret float 2.000000e+00
39 %val = call float @llvm.amdgcn.rcp.f32(float 0.5) nounwind readnone
43 define double @test_constant_fold_rcp_f64_half() nounwind {
44 ; CHECK-LABEL: @test_constant_fold_rcp_f64_half(
45 ; CHECK-NEXT: ret double 2.000000e+00
47 %val = call double @llvm.amdgcn.rcp.f64(double 0.5) nounwind readnone
51 define float @test_constant_fold_rcp_f32_43() nounwind {
52 ; CHECK-LABEL: @test_constant_fold_rcp_f32_43(
53 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.amdgcn.rcp.f32(float 4.300000e+01)
54 ; CHECK-NEXT: ret float [[VAL]]
56 %val = call float @llvm.amdgcn.rcp.f32(float 4.300000e+01) nounwind readnone
60 define double @test_constant_fold_rcp_f64_43() nounwind {
61 ; CHECK-LABEL: @test_constant_fold_rcp_f64_43(
62 ; CHECK-NEXT: [[VAL:%.*]] = call double @llvm.amdgcn.rcp.f64(double 4.300000e+01)
63 ; CHECK-NEXT: ret double [[VAL]]
65 %val = call double @llvm.amdgcn.rcp.f64(double 4.300000e+01) nounwind readnone
69 ; --------------------------------------------------------------------
71 ; --------------------------------------------------------------------
73 declare float @llvm.amdgcn.rsq.f32(float) nounwind readnone
75 define float @test_constant_fold_rsq_f32_undef() nounwind {
76 ; CHECK-LABEL: @test_constant_fold_rsq_f32_undef(
77 ; CHECK-NEXT: ret float undef
79 %val = call float @llvm.amdgcn.rsq.f32(float undef) nounwind readnone
83 ; --------------------------------------------------------------------
84 ; llvm.amdgcn.frexp.mant
85 ; --------------------------------------------------------------------
87 declare float @llvm.amdgcn.frexp.mant.f32(float) nounwind readnone
88 declare double @llvm.amdgcn.frexp.mant.f64(double) nounwind readnone
91 define float @test_constant_fold_frexp_mant_f32_undef() nounwind {
92 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_undef(
93 ; CHECK-NEXT: ret float undef
95 %val = call float @llvm.amdgcn.frexp.mant.f32(float undef)
99 define double @test_constant_fold_frexp_mant_f64_undef() nounwind {
100 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_undef(
101 ; CHECK-NEXT: ret double undef
103 %val = call double @llvm.amdgcn.frexp.mant.f64(double undef)
107 define float @test_constant_fold_frexp_mant_f32_0() nounwind {
108 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_0(
109 ; CHECK-NEXT: ret float 0.000000e+00
111 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0.0)
115 define double @test_constant_fold_frexp_mant_f64_0() nounwind {
116 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_0(
117 ; CHECK-NEXT: ret double 0.000000e+00
119 %val = call double @llvm.amdgcn.frexp.mant.f64(double 0.0)
123 define float @test_constant_fold_frexp_mant_f32_n0() nounwind {
124 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_n0(
125 ; CHECK-NEXT: ret float -0.000000e+00
127 %val = call float @llvm.amdgcn.frexp.mant.f32(float -0.0)
131 define double @test_constant_fold_frexp_mant_f64_n0() nounwind {
132 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_n0(
133 ; CHECK-NEXT: ret double -0.000000e+00
135 %val = call double @llvm.amdgcn.frexp.mant.f64(double -0.0)
139 define float @test_constant_fold_frexp_mant_f32_1() nounwind {
140 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_1(
141 ; CHECK-NEXT: ret float 5.000000e-01
143 %val = call float @llvm.amdgcn.frexp.mant.f32(float 1.0)
147 define double @test_constant_fold_frexp_mant_f64_1() nounwind {
148 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_1(
149 ; CHECK-NEXT: ret double 5.000000e-01
151 %val = call double @llvm.amdgcn.frexp.mant.f64(double 1.0)
155 define float @test_constant_fold_frexp_mant_f32_n1() nounwind {
156 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_n1(
157 ; CHECK-NEXT: ret float -5.000000e-01
159 %val = call float @llvm.amdgcn.frexp.mant.f32(float -1.0)
163 define double @test_constant_fold_frexp_mant_f64_n1() nounwind {
164 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_n1(
165 ; CHECK-NEXT: ret double -5.000000e-01
167 %val = call double @llvm.amdgcn.frexp.mant.f64(double -1.0)
171 define float @test_constant_fold_frexp_mant_f32_nan() nounwind {
172 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_nan(
173 ; CHECK-NEXT: ret float 0x7FF8000000000000
175 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x7FF8000000000000)
179 define double @test_constant_fold_frexp_mant_f64_nan() nounwind {
180 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_nan(
181 ; CHECK-NEXT: ret double 0x7FF8000000000000
183 %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FF8000000000000)
187 define float @test_constant_fold_frexp_mant_f32_inf() nounwind {
188 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_inf(
189 ; CHECK-NEXT: ret float 0x7FF0000000000000
191 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x7FF0000000000000)
195 define double @test_constant_fold_frexp_mant_f64_inf() nounwind {
196 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_inf(
197 ; CHECK-NEXT: ret double 0x7FF0000000000000
199 %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FF0000000000000)
203 define float @test_constant_fold_frexp_mant_f32_ninf() nounwind {
204 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_ninf(
205 ; CHECK-NEXT: ret float 0xFFF0000000000000
207 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0xFFF0000000000000)
211 define double @test_constant_fold_frexp_mant_f64_ninf() nounwind {
212 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_ninf(
213 ; CHECK-NEXT: ret double 0xFFF0000000000000
215 %val = call double @llvm.amdgcn.frexp.mant.f64(double 0xFFF0000000000000)
219 define float @test_constant_fold_frexp_mant_f32_max_num() nounwind {
220 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_max_num(
221 ; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
223 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x47EFFFFFE0000000)
227 define double @test_constant_fold_frexp_mant_f64_max_num() nounwind {
228 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_max_num(
229 ; CHECK-NEXT: ret double 0x3FEFFFFFFFFFFFFF
231 %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FEFFFFFFFFFFFFF)
235 define float @test_constant_fold_frexp_mant_f32_min_num() nounwind {
236 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_min_num(
237 ; CHECK-NEXT: ret float 5.000000e-01
239 %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x36A0000000000000)
243 define double @test_constant_fold_frexp_mant_f64_min_num() nounwind {
244 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_min_num(
245 ; CHECK-NEXT: ret double 5.000000e-01
247 %val = call double @llvm.amdgcn.frexp.mant.f64(double 4.940656e-324)
252 ; --------------------------------------------------------------------
253 ; llvm.amdgcn.frexp.exp
254 ; --------------------------------------------------------------------
256 declare i32 @llvm.amdgcn.frexp.exp.f32(float) nounwind readnone
257 declare i32 @llvm.amdgcn.frexp.exp.f64(double) nounwind readnone
259 define i32 @test_constant_fold_frexp_exp_f32_undef() nounwind {
260 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_undef(
261 ; CHECK-NEXT: ret i32 undef
263 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float undef)
267 define i32 @test_constant_fold_frexp_exp_f64_undef() nounwind {
268 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_undef(
269 ; CHECK-NEXT: ret i32 undef
271 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double undef)
275 define i32 @test_constant_fold_frexp_exp_f32_0() nounwind {
276 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_0(
277 ; CHECK-NEXT: ret i32 0
279 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0.0)
283 define i32 @test_constant_fold_frexp_exp_f64_0() nounwind {
284 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_0(
285 ; CHECK-NEXT: ret i32 0
287 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0.0)
291 define i32 @test_constant_fold_frexp_exp_f32_n0() nounwind {
292 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_n0(
293 ; CHECK-NEXT: ret i32 0
295 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float -0.0)
299 define i32 @test_constant_fold_frexp_exp_f64_n0() nounwind {
300 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_n0(
301 ; CHECK-NEXT: ret i32 0
303 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double -0.0)
307 define i32 @test_constant_fold_frexp_exp_f32_1024() nounwind {
308 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_1024(
309 ; CHECK-NEXT: ret i32 11
311 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 1024.0)
315 define i32 @test_constant_fold_frexp_exp_f64_1024() nounwind {
316 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_1024(
317 ; CHECK-NEXT: ret i32 11
319 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 1024.0)
323 define i32 @test_constant_fold_frexp_exp_f32_n1024() nounwind {
324 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_n1024(
325 ; CHECK-NEXT: ret i32 11
327 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float -1024.0)
331 define i32 @test_constant_fold_frexp_exp_f64_n1024() nounwind {
332 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_n1024(
333 ; CHECK-NEXT: ret i32 11
335 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double -1024.0)
339 define i32 @test_constant_fold_frexp_exp_f32_1_1024() nounwind {
340 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_1_1024(
341 ; CHECK-NEXT: ret i32 -9
343 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0.0009765625)
347 define i32 @test_constant_fold_frexp_exp_f64_1_1024() nounwind {
348 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_1_1024(
349 ; CHECK-NEXT: ret i32 -9
351 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0.0009765625)
355 define i32 @test_constant_fold_frexp_exp_f32_nan() nounwind {
356 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_nan(
357 ; CHECK-NEXT: ret i32 0
359 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x7FF8000000000000)
363 define i32 @test_constant_fold_frexp_exp_f64_nan() nounwind {
364 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_nan(
365 ; CHECK-NEXT: ret i32 0
367 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FF8000000000000)
371 define i32 @test_constant_fold_frexp_exp_f32_inf() nounwind {
372 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_inf(
373 ; CHECK-NEXT: ret i32 0
375 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x7FF0000000000000)
379 define i32 @test_constant_fold_frexp_exp_f64_inf() nounwind {
380 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_inf(
381 ; CHECK-NEXT: ret i32 0
383 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FF0000000000000)
387 define i32 @test_constant_fold_frexp_exp_f32_ninf() nounwind {
388 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_ninf(
389 ; CHECK-NEXT: ret i32 0
391 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0xFFF0000000000000)
395 define i32 @test_constant_fold_frexp_exp_f64_ninf() nounwind {
396 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_ninf(
397 ; CHECK-NEXT: ret i32 0
399 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0xFFF0000000000000)
403 define i32 @test_constant_fold_frexp_exp_f32_max_num() nounwind {
404 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_max_num(
405 ; CHECK-NEXT: ret i32 128
407 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x47EFFFFFE0000000)
411 define i32 @test_constant_fold_frexp_exp_f64_max_num() nounwind {
412 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_max_num(
413 ; CHECK-NEXT: ret i32 1024
415 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FEFFFFFFFFFFFFF)
419 define i32 @test_constant_fold_frexp_exp_f32_min_num() nounwind {
420 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_min_num(
421 ; CHECK-NEXT: ret i32 -148
423 %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x36A0000000000000)
427 define i32 @test_constant_fold_frexp_exp_f64_min_num() nounwind {
428 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_min_num(
429 ; CHECK-NEXT: ret i32 -1073
431 %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 4.940656e-324)
435 ; --------------------------------------------------------------------
437 ; --------------------------------------------------------------------
439 declare i1 @llvm.amdgcn.class.f32(float, i32) nounwind readnone
440 declare i1 @llvm.amdgcn.class.f64(double, i32) nounwind readnone
442 define i1 @test_class_undef_mask_f32(float %x) nounwind {
443 ; CHECK-LABEL: @test_class_undef_mask_f32(
444 ; CHECK-NEXT: ret i1 false
446 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 undef)
450 define i1 @test_class_over_max_mask_f32(float %x) nounwind {
451 ; CHECK-LABEL: @test_class_over_max_mask_f32(
452 ; CHECK-NEXT: [[VAL:%.*]] = call i1 @llvm.amdgcn.class.f32(float [[X:%.*]], i32 1)
453 ; CHECK-NEXT: ret i1 [[VAL]]
455 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 1025)
459 define i1 @test_class_no_mask_f32(float %x) nounwind {
460 ; CHECK-LABEL: @test_class_no_mask_f32(
461 ; CHECK-NEXT: ret i1 false
463 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 0)
467 define i1 @test_class_full_mask_f32(float %x) nounwind {
468 ; CHECK-LABEL: @test_class_full_mask_f32(
469 ; CHECK-NEXT: ret i1 true
471 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 1023)
475 define i1 @test_class_undef_no_mask_f32() nounwind {
476 ; CHECK-LABEL: @test_class_undef_no_mask_f32(
477 ; CHECK-NEXT: ret i1 false
479 %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 0)
483 define i1 @test_class_undef_full_mask_f32() nounwind {
484 ; CHECK-LABEL: @test_class_undef_full_mask_f32(
485 ; CHECK-NEXT: ret i1 true
487 %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 1023)
491 define i1 @test_class_undef_val_f32() nounwind {
492 ; CHECK-LABEL: @test_class_undef_val_f32(
493 ; CHECK-NEXT: ret i1 undef
495 %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 4)
499 define i1 @test_class_undef_undef_f32() nounwind {
500 ; CHECK-LABEL: @test_class_undef_undef_f32(
501 ; CHECK-NEXT: ret i1 undef
503 %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 undef)
507 define i1 @test_class_var_mask_f32(float %x, i32 %mask) nounwind {
508 ; CHECK-LABEL: @test_class_var_mask_f32(
509 ; CHECK-NEXT: [[VAL:%.*]] = call i1 @llvm.amdgcn.class.f32(float [[X:%.*]], i32 [[MASK:%.*]])
510 ; CHECK-NEXT: ret i1 [[VAL]]
512 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 %mask)
516 define i1 @test_class_isnan_f32(float %x) nounwind {
517 ; CHECK-LABEL: @test_class_isnan_f32(
518 ; CHECK-NEXT: [[VAL:%.*]] = fcmp uno float [[X:%.*]], 0.000000e+00
519 ; CHECK-NEXT: ret i1 [[VAL]]
521 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 3)
525 define i1 @test_class_is_p0_n0_f32(float %x) nounwind {
526 ; CHECK-LABEL: @test_class_is_p0_n0_f32(
527 ; CHECK-NEXT: [[VAL:%.*]] = fcmp oeq float [[X:%.*]], 0.000000e+00
528 ; CHECK-NEXT: ret i1 [[VAL]]
530 %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 96)
534 define i1 @test_constant_class_snan_test_snan_f64() nounwind {
535 ; CHECK-LABEL: @test_constant_class_snan_test_snan_f64(
536 ; CHECK-NEXT: ret i1 true
538 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 1)
542 define i1 @test_constant_class_qnan_test_qnan_f64() nounwind {
543 ; CHECK-LABEL: @test_constant_class_qnan_test_qnan_f64(
544 ; CHECK-NEXT: ret i1 true
546 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 2)
550 define i1 @test_constant_class_qnan_test_snan_f64() nounwind {
551 ; CHECK-LABEL: @test_constant_class_qnan_test_snan_f64(
552 ; CHECK-NEXT: ret i1 false
554 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 1)
558 define i1 @test_constant_class_ninf_test_ninf_f64() nounwind {
559 ; CHECK-LABEL: @test_constant_class_ninf_test_ninf_f64(
560 ; CHECK-NEXT: ret i1 true
562 %val = call i1 @llvm.amdgcn.class.f64(double 0xFFF0000000000000, i32 4)
566 define i1 @test_constant_class_pinf_test_ninf_f64() nounwind {
567 ; CHECK-LABEL: @test_constant_class_pinf_test_ninf_f64(
568 ; CHECK-NEXT: ret i1 false
570 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000000, i32 4)
574 define i1 @test_constant_class_qnan_test_ninf_f64() nounwind {
575 ; CHECK-LABEL: @test_constant_class_qnan_test_ninf_f64(
576 ; CHECK-NEXT: ret i1 false
578 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 4)
582 define i1 @test_constant_class_snan_test_ninf_f64() nounwind {
583 ; CHECK-LABEL: @test_constant_class_snan_test_ninf_f64(
584 ; CHECK-NEXT: ret i1 false
586 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 4)
590 define i1 @test_constant_class_nnormal_test_nnormal_f64() nounwind {
591 ; CHECK-LABEL: @test_constant_class_nnormal_test_nnormal_f64(
592 ; CHECK-NEXT: ret i1 true
594 %val = call i1 @llvm.amdgcn.class.f64(double -1.0, i32 8)
598 define i1 @test_constant_class_pnormal_test_nnormal_f64() nounwind {
599 ; CHECK-LABEL: @test_constant_class_pnormal_test_nnormal_f64(
600 ; CHECK-NEXT: ret i1 false
602 %val = call i1 @llvm.amdgcn.class.f64(double 1.0, i32 8)
606 define i1 @test_constant_class_nsubnormal_test_nsubnormal_f64() nounwind {
607 ; CHECK-LABEL: @test_constant_class_nsubnormal_test_nsubnormal_f64(
608 ; CHECK-NEXT: ret i1 true
610 %val = call i1 @llvm.amdgcn.class.f64(double 0x800fffffffffffff, i32 16)
614 define i1 @test_constant_class_psubnormal_test_nsubnormal_f64() nounwind {
615 ; CHECK-LABEL: @test_constant_class_psubnormal_test_nsubnormal_f64(
616 ; CHECK-NEXT: ret i1 false
618 %val = call i1 @llvm.amdgcn.class.f64(double 0x000fffffffffffff, i32 16)
622 define i1 @test_constant_class_nzero_test_nzero_f64() nounwind {
623 ; CHECK-LABEL: @test_constant_class_nzero_test_nzero_f64(
624 ; CHECK-NEXT: ret i1 true
626 %val = call i1 @llvm.amdgcn.class.f64(double -0.0, i32 32)
630 define i1 @test_constant_class_pzero_test_nzero_f64() nounwind {
631 ; CHECK-LABEL: @test_constant_class_pzero_test_nzero_f64(
632 ; CHECK-NEXT: ret i1 false
634 %val = call i1 @llvm.amdgcn.class.f64(double 0.0, i32 32)
638 define i1 @test_constant_class_pzero_test_pzero_f64() nounwind {
639 ; CHECK-LABEL: @test_constant_class_pzero_test_pzero_f64(
640 ; CHECK-NEXT: ret i1 true
642 %val = call i1 @llvm.amdgcn.class.f64(double 0.0, i32 64)
646 define i1 @test_constant_class_nzero_test_pzero_f64() nounwind {
647 ; CHECK-LABEL: @test_constant_class_nzero_test_pzero_f64(
648 ; CHECK-NEXT: ret i1 false
650 %val = call i1 @llvm.amdgcn.class.f64(double -0.0, i32 64)
654 define i1 @test_constant_class_psubnormal_test_psubnormal_f64() nounwind {
655 ; CHECK-LABEL: @test_constant_class_psubnormal_test_psubnormal_f64(
656 ; CHECK-NEXT: ret i1 true
658 %val = call i1 @llvm.amdgcn.class.f64(double 0x000fffffffffffff, i32 128)
662 define i1 @test_constant_class_nsubnormal_test_psubnormal_f64() nounwind {
663 ; CHECK-LABEL: @test_constant_class_nsubnormal_test_psubnormal_f64(
664 ; CHECK-NEXT: ret i1 false
666 %val = call i1 @llvm.amdgcn.class.f64(double 0x800fffffffffffff, i32 128)
670 define i1 @test_constant_class_pnormal_test_pnormal_f64() nounwind {
671 ; CHECK-LABEL: @test_constant_class_pnormal_test_pnormal_f64(
672 ; CHECK-NEXT: ret i1 true
674 %val = call i1 @llvm.amdgcn.class.f64(double 1.0, i32 256)
678 define i1 @test_constant_class_nnormal_test_pnormal_f64() nounwind {
679 ; CHECK-LABEL: @test_constant_class_nnormal_test_pnormal_f64(
680 ; CHECK-NEXT: ret i1 false
682 %val = call i1 @llvm.amdgcn.class.f64(double -1.0, i32 256)
686 define i1 @test_constant_class_pinf_test_pinf_f64() nounwind {
687 ; CHECK-LABEL: @test_constant_class_pinf_test_pinf_f64(
688 ; CHECK-NEXT: ret i1 true
690 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000000, i32 512)
694 define i1 @test_constant_class_ninf_test_pinf_f64() nounwind {
695 ; CHECK-LABEL: @test_constant_class_ninf_test_pinf_f64(
696 ; CHECK-NEXT: ret i1 false
698 %val = call i1 @llvm.amdgcn.class.f64(double 0xFFF0000000000000, i32 512)
702 define i1 @test_constant_class_qnan_test_pinf_f64() nounwind {
703 ; CHECK-LABEL: @test_constant_class_qnan_test_pinf_f64(
704 ; CHECK-NEXT: ret i1 false
706 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 512)
710 define i1 @test_constant_class_snan_test_pinf_f64() nounwind {
711 ; CHECK-LABEL: @test_constant_class_snan_test_pinf_f64(
712 ; CHECK-NEXT: ret i1 false
714 %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 512)
718 define i1 @test_class_is_snan_nnan_src(float %x) {
719 ; CHECK-LABEL: @test_class_is_snan_nnan_src(
720 ; CHECK-NEXT: ret i1 false
722 %nnan = fadd nnan float %x, 1.0
723 %class = call i1 @llvm.amdgcn.class.f32(float %nnan, i32 1)
727 define i1 @test_class_is_qnan_nnan_src(float %x) {
728 ; CHECK-LABEL: @test_class_is_qnan_nnan_src(
729 ; CHECK-NEXT: ret i1 false
731 %nnan = fadd nnan float %x, 1.0
732 %class = call i1 @llvm.amdgcn.class.f32(float %nnan, i32 2)
736 define i1 @test_class_is_nan_nnan_src(float %x) {
737 ; CHECK-LABEL: @test_class_is_nan_nnan_src(
738 ; CHECK-NEXT: ret i1 false
740 %nnan = fadd nnan float %x, 1.0
741 %class = call i1 @llvm.amdgcn.class.f32(float %nnan, i32 3)
745 define i1 @test_class_is_nan_other_nnan_src(float %x) {
746 ; CHECK-LABEL: @test_class_is_nan_other_nnan_src(
747 ; CHECK-NEXT: [[NNAN:%.*]] = fadd nnan float [[X:%.*]], 1.000000e+00
748 ; CHECK-NEXT: [[CLASS:%.*]] = call i1 @llvm.amdgcn.class.f32(float [[NNAN]], i32 264)
749 ; CHECK-NEXT: ret i1 [[CLASS]]
751 %nnan = fadd nnan float %x, 1.0
752 %class = call i1 @llvm.amdgcn.class.f32(float %nnan, i32 267)
756 ; --------------------------------------------------------------------
758 ; --------------------------------------------------------------------
759 declare float @llvm.amdgcn.cos.f32(float) nounwind readnone
760 declare float @llvm.fabs.f32(float) nounwind readnone
762 define float @cos_fneg_f32(float %x) {
763 ; CHECK-LABEL: @cos_fneg_f32(
764 ; CHECK-NEXT: [[COS:%.*]] = call float @llvm.amdgcn.cos.f32(float [[X:%.*]])
765 ; CHECK-NEXT: ret float [[COS]]
767 %x.fneg = fsub float -0.0, %x
768 %cos = call float @llvm.amdgcn.cos.f32(float %x.fneg)
772 define float @cos_unary_fneg_f32(float %x) {
773 ; CHECK-LABEL: @cos_unary_fneg_f32(
774 ; CHECK-NEXT: [[COS:%.*]] = call float @llvm.amdgcn.cos.f32(float [[X:%.*]])
775 ; CHECK-NEXT: ret float [[COS]]
777 %x.fneg = fneg float %x
778 %cos = call float @llvm.amdgcn.cos.f32(float %x.fneg)
782 define float @cos_fabs_f32(float %x) {
783 ; CHECK-LABEL: @cos_fabs_f32(
784 ; CHECK-NEXT: [[COS:%.*]] = call float @llvm.amdgcn.cos.f32(float [[X:%.*]])
785 ; CHECK-NEXT: ret float [[COS]]
787 %x.fabs = call float @llvm.fabs.f32(float %x)
788 %cos = call float @llvm.amdgcn.cos.f32(float %x.fabs)
792 define float @cos_fabs_fneg_f32(float %x) {
793 ; CHECK-LABEL: @cos_fabs_fneg_f32(
794 ; CHECK-NEXT: [[COS:%.*]] = call float @llvm.amdgcn.cos.f32(float [[X:%.*]])
795 ; CHECK-NEXT: ret float [[COS]]
797 %x.fabs = call float @llvm.fabs.f32(float %x)
798 %x.fabs.fneg = fsub float -0.0, %x.fabs
799 %cos = call float @llvm.amdgcn.cos.f32(float %x.fabs.fneg)
803 define float @cos_fabs_unary_fneg_f32(float %x) {
804 ; CHECK-LABEL: @cos_fabs_unary_fneg_f32(
805 ; CHECK-NEXT: [[COS:%.*]] = call float @llvm.amdgcn.cos.f32(float [[X:%.*]])
806 ; CHECK-NEXT: ret float [[COS]]
808 %x.fabs = call float @llvm.fabs.f32(float %x)
809 %x.fabs.fneg = fneg float %x.fabs
810 %cos = call float @llvm.amdgcn.cos.f32(float %x.fabs.fneg)
814 ; --------------------------------------------------------------------
815 ; llvm.amdgcn.cvt.pkrtz
816 ; --------------------------------------------------------------------
818 declare <2 x half> @llvm.amdgcn.cvt.pkrtz(float, float) nounwind readnone
820 define <2 x half> @vars_lhs_cvt_pkrtz(float %x, float %y) {
821 ; CHECK-LABEL: @vars_lhs_cvt_pkrtz(
822 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float [[X:%.*]], float [[Y:%.*]])
823 ; CHECK-NEXT: ret <2 x half> [[CVT]]
825 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float %x, float %y)
829 define <2 x half> @constant_lhs_cvt_pkrtz(float %y) {
830 ; CHECK-LABEL: @constant_lhs_cvt_pkrtz(
831 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float 0.000000e+00, float [[Y:%.*]])
832 ; CHECK-NEXT: ret <2 x half> [[CVT]]
834 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float 0.0, float %y)
838 define <2 x half> @constant_rhs_cvt_pkrtz(float %x) {
839 ; CHECK-LABEL: @constant_rhs_cvt_pkrtz(
840 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float [[X:%.*]], float 0.000000e+00)
841 ; CHECK-NEXT: ret <2 x half> [[CVT]]
843 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float %x, float 0.0)
847 define <2 x half> @undef_lhs_cvt_pkrtz(float %y) {
848 ; CHECK-LABEL: @undef_lhs_cvt_pkrtz(
849 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float undef, float [[Y:%.*]])
850 ; CHECK-NEXT: ret <2 x half> [[CVT]]
852 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float undef, float %y)
856 define <2 x half> @undef_rhs_cvt_pkrtz(float %x) {
857 ; CHECK-LABEL: @undef_rhs_cvt_pkrtz(
858 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float [[X:%.*]], float undef)
859 ; CHECK-NEXT: ret <2 x half> [[CVT]]
861 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float %x, float undef)
865 define <2 x half> @undef_cvt_pkrtz() {
866 ; CHECK-LABEL: @undef_cvt_pkrtz(
867 ; CHECK-NEXT: ret <2 x half> undef
869 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float undef, float undef)
873 define <2 x half> @constant_splat0_cvt_pkrtz() {
874 ; CHECK-LABEL: @constant_splat0_cvt_pkrtz(
875 ; CHECK-NEXT: ret <2 x half> zeroinitializer
877 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float 0.0, float 0.0)
881 define <2 x half> @constant_cvt_pkrtz() {
882 ; CHECK-LABEL: @constant_cvt_pkrtz(
883 ; CHECK-NEXT: ret <2 x half> <half 0xH4000, half 0xH4400>
885 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float 2.0, float 4.0)
889 ; Test constant values where rtz changes result
890 define <2 x half> @constant_rtz_pkrtz() {
891 ; CHECK-LABEL: @constant_rtz_pkrtz(
892 ; CHECK-NEXT: ret <2 x half> <half 0xH7BFF, half 0xH7BFF>
894 %cvt = call <2 x half> @llvm.amdgcn.cvt.pkrtz(float 65535.0, float 65535.0)
898 ; --------------------------------------------------------------------
899 ; llvm.amdgcn.cvt.pknorm.i16
900 ; --------------------------------------------------------------------
902 declare <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float, float) nounwind readnone
904 define <2 x i16> @undef_lhs_cvt_pknorm_i16(float %y) {
905 ; CHECK-LABEL: @undef_lhs_cvt_pknorm_i16(
906 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float undef, float [[Y:%.*]])
907 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
909 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float undef, float %y)
913 define <2 x i16> @undef_rhs_cvt_pknorm_i16(float %x) {
914 ; CHECK-LABEL: @undef_rhs_cvt_pknorm_i16(
915 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float [[X:%.*]], float undef)
916 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
918 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float %x, float undef)
922 define <2 x i16> @undef_cvt_pknorm_i16() {
923 ; CHECK-LABEL: @undef_cvt_pknorm_i16(
924 ; CHECK-NEXT: ret <2 x i16> undef
926 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float undef, float undef)
930 ; --------------------------------------------------------------------
931 ; llvm.amdgcn.cvt.pknorm.u16
932 ; --------------------------------------------------------------------
934 declare <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float, float) nounwind readnone
936 define <2 x i16> @undef_lhs_cvt_pknorm_u16(float %y) {
937 ; CHECK-LABEL: @undef_lhs_cvt_pknorm_u16(
938 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float undef, float [[Y:%.*]])
939 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
941 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float undef, float %y)
945 define <2 x i16> @undef_rhs_cvt_pknorm_u16(float %x) {
946 ; CHECK-LABEL: @undef_rhs_cvt_pknorm_u16(
947 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float [[X:%.*]], float undef)
948 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
950 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float %x, float undef)
954 define <2 x i16> @undef_cvt_pknorm_u16() {
955 ; CHECK-LABEL: @undef_cvt_pknorm_u16(
956 ; CHECK-NEXT: ret <2 x i16> undef
958 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float undef, float undef)
962 ; --------------------------------------------------------------------
963 ; llvm.amdgcn.cvt.pk.i16
964 ; --------------------------------------------------------------------
966 declare <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32, i32) nounwind readnone
968 define <2 x i16> @undef_lhs_cvt_pk_i16(i32 %y) {
969 ; CHECK-LABEL: @undef_lhs_cvt_pk_i16(
970 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 undef, i32 [[Y:%.*]])
971 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
973 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 undef, i32 %y)
977 define <2 x i16> @undef_rhs_cvt_pk_i16(i32 %x) {
978 ; CHECK-LABEL: @undef_rhs_cvt_pk_i16(
979 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 [[X:%.*]], i32 undef)
980 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
982 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 %x, i32 undef)
986 define <2 x i16> @undef_cvt_pk_i16() {
987 ; CHECK-LABEL: @undef_cvt_pk_i16(
988 ; CHECK-NEXT: ret <2 x i16> undef
990 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 undef, i32 undef)
994 ; --------------------------------------------------------------------
995 ; llvm.amdgcn.cvt.pk.u16
996 ; --------------------------------------------------------------------
998 declare <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32, i32) nounwind readnone
1000 define <2 x i16> @undef_lhs_cvt_pk_u16(i32 %y) {
1001 ; CHECK-LABEL: @undef_lhs_cvt_pk_u16(
1002 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 undef, i32 [[Y:%.*]])
1003 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
1005 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 undef, i32 %y)
1009 define <2 x i16> @undef_rhs_cvt_pk_u16(i32 %x) {
1010 ; CHECK-LABEL: @undef_rhs_cvt_pk_u16(
1011 ; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 [[X:%.*]], i32 undef)
1012 ; CHECK-NEXT: ret <2 x i16> [[CVT]]
1014 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 %x, i32 undef)
1018 define <2 x i16> @undef_cvt_pk_u16() {
1019 ; CHECK-LABEL: @undef_cvt_pk_u16(
1020 ; CHECK-NEXT: ret <2 x i16> undef
1022 %cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 undef, i32 undef)
1026 ; --------------------------------------------------------------------
1028 ; --------------------------------------------------------------------
1030 declare i32 @llvm.amdgcn.ubfe.i32(i32, i32, i32) nounwind readnone
1031 declare i64 @llvm.amdgcn.ubfe.i64(i64, i32, i32) nounwind readnone
1033 define i32 @ubfe_var_i32(i32 %src, i32 %offset, i32 %width) {
1034 ; CHECK-LABEL: @ubfe_var_i32(
1035 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 [[OFFSET:%.*]], i32 [[WIDTH:%.*]])
1036 ; CHECK-NEXT: ret i32 [[BFE]]
1038 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 %width)
1042 define i32 @ubfe_clear_high_bits_constant_offset_i32(i32 %src, i32 %width) {
1043 ; CHECK-LABEL: @ubfe_clear_high_bits_constant_offset_i32(
1044 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 5, i32 [[WIDTH:%.*]])
1045 ; CHECK-NEXT: ret i32 [[BFE]]
1047 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 133, i32 %width)
1051 define i32 @ubfe_clear_high_bits_constant_width_i32(i32 %src, i32 %offset) {
1052 ; CHECK-LABEL: @ubfe_clear_high_bits_constant_width_i32(
1053 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 [[OFFSET:%.*]], i32 5)
1054 ; CHECK-NEXT: ret i32 [[BFE]]
1056 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 133)
1060 define i32 @ubfe_width_0(i32 %src, i32 %offset) {
1061 ; CHECK-LABEL: @ubfe_width_0(
1062 ; CHECK-NEXT: ret i32 0
1064 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 0)
1068 define i32 @ubfe_width_31(i32 %src, i32 %offset) {
1069 ; CHECK-LABEL: @ubfe_width_31(
1070 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 [[OFFSET:%.*]], i32 31)
1071 ; CHECK-NEXT: ret i32 [[BFE]]
1073 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 31)
1077 define i32 @ubfe_width_32(i32 %src, i32 %offset) {
1078 ; CHECK-LABEL: @ubfe_width_32(
1079 ; CHECK-NEXT: ret i32 0
1081 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 32)
1085 define i32 @ubfe_width_33(i32 %src, i32 %offset) {
1086 ; CHECK-LABEL: @ubfe_width_33(
1087 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 [[OFFSET:%.*]], i32 1)
1088 ; CHECK-NEXT: ret i32 [[BFE]]
1090 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 33)
1094 define i32 @ubfe_offset_33(i32 %src, i32 %width) {
1095 ; CHECK-LABEL: @ubfe_offset_33(
1096 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 1, i32 [[WIDTH:%.*]])
1097 ; CHECK-NEXT: ret i32 [[BFE]]
1099 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 33, i32 %width)
1103 define i32 @ubfe_offset_0(i32 %src, i32 %width) {
1104 ; CHECK-LABEL: @ubfe_offset_0(
1105 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 0, i32 [[WIDTH:%.*]])
1106 ; CHECK-NEXT: ret i32 [[BFE]]
1108 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 0, i32 %width)
1112 define i32 @ubfe_offset_32(i32 %src, i32 %width) {
1113 ; CHECK-LABEL: @ubfe_offset_32(
1114 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 0, i32 [[WIDTH:%.*]])
1115 ; CHECK-NEXT: ret i32 [[BFE]]
1117 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 32, i32 %width)
1121 define i32 @ubfe_offset_31(i32 %src, i32 %width) {
1122 ; CHECK-LABEL: @ubfe_offset_31(
1123 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 31, i32 [[WIDTH:%.*]])
1124 ; CHECK-NEXT: ret i32 [[BFE]]
1126 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 31, i32 %width)
1130 define i32 @ubfe_offset_0_width_0(i32 %src) {
1131 ; CHECK-LABEL: @ubfe_offset_0_width_0(
1132 ; CHECK-NEXT: ret i32 0
1134 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 0, i32 0)
1138 define i32 @ubfe_offset_0_width_3(i32 %src) {
1139 ; CHECK-LABEL: @ubfe_offset_0_width_3(
1140 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[SRC:%.*]], 7
1141 ; CHECK-NEXT: ret i32 [[TMP1]]
1143 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 0, i32 3)
1147 define i32 @ubfe_offset_3_width_1(i32 %src) {
1148 ; CHECK-LABEL: @ubfe_offset_3_width_1(
1149 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[SRC:%.*]], 3
1150 ; CHECK-NEXT: [[BFE:%.*]] = and i32 [[TMP1]], 1
1151 ; CHECK-NEXT: ret i32 [[BFE]]
1153 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 3, i32 1)
1157 define i32 @ubfe_offset_3_width_4(i32 %src) {
1158 ; CHECK-LABEL: @ubfe_offset_3_width_4(
1159 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[SRC:%.*]], 3
1160 ; CHECK-NEXT: [[BFE:%.*]] = and i32 [[TMP1]], 15
1161 ; CHECK-NEXT: ret i32 [[BFE]]
1163 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 3, i32 4)
1167 define i32 @ubfe_0_0_0() {
1168 ; CHECK-LABEL: @ubfe_0_0_0(
1169 ; CHECK-NEXT: ret i32 0
1171 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 0, i32 0, i32 0)
1175 define i32 @ubfe_neg1_5_7() {
1176 ; CHECK-LABEL: @ubfe_neg1_5_7(
1177 ; CHECK-NEXT: ret i32 127
1179 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 -1, i32 5, i32 7)
1183 define i32 @ubfe_undef_src_i32(i32 %offset, i32 %width) {
1184 ; CHECK-LABEL: @ubfe_undef_src_i32(
1185 ; CHECK-NEXT: ret i32 undef
1187 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 undef, i32 %offset, i32 %width)
1191 define i32 @ubfe_undef_offset_i32(i32 %src, i32 %width) {
1192 ; CHECK-LABEL: @ubfe_undef_offset_i32(
1193 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 undef, i32 [[WIDTH:%.*]])
1194 ; CHECK-NEXT: ret i32 [[BFE]]
1196 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 undef, i32 %width)
1200 define i32 @ubfe_undef_width_i32(i32 %src, i32 %offset) {
1201 ; CHECK-LABEL: @ubfe_undef_width_i32(
1202 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.ubfe.i32(i32 [[SRC:%.*]], i32 [[OFFSET:%.*]], i32 undef)
1203 ; CHECK-NEXT: ret i32 [[BFE]]
1205 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 %src, i32 %offset, i32 undef)
1209 define i64 @ubfe_offset_33_width_4_i64(i64 %src) {
1210 ; CHECK-LABEL: @ubfe_offset_33_width_4_i64(
1211 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[SRC:%.*]], 33
1212 ; CHECK-NEXT: [[BFE:%.*]] = and i64 [[TMP1]], 15
1213 ; CHECK-NEXT: ret i64 [[BFE]]
1215 %bfe = call i64 @llvm.amdgcn.ubfe.i64(i64 %src, i32 33, i32 4)
1219 define i64 @ubfe_offset_0_i64(i64 %src, i32 %width) {
1220 ; CHECK-LABEL: @ubfe_offset_0_i64(
1221 ; CHECK-NEXT: [[BFE:%.*]] = call i64 @llvm.amdgcn.ubfe.i64(i64 [[SRC:%.*]], i32 0, i32 [[WIDTH:%.*]])
1222 ; CHECK-NEXT: ret i64 [[BFE]]
1224 %bfe = call i64 @llvm.amdgcn.ubfe.i64(i64 %src, i32 0, i32 %width)
1228 define i64 @ubfe_offset_32_width_32_i64(i64 %src) {
1229 ; CHECK-LABEL: @ubfe_offset_32_width_32_i64(
1230 ; CHECK-NEXT: [[BFE:%.*]] = lshr i64 [[SRC:%.*]], 32
1231 ; CHECK-NEXT: ret i64 [[BFE]]
1233 %bfe = call i64 @llvm.amdgcn.ubfe.i64(i64 %src, i32 32, i32 32)
1237 ; --------------------------------------------------------------------
1239 ; --------------------------------------------------------------------
1241 declare i32 @llvm.amdgcn.sbfe.i32(i32, i32, i32) nounwind readnone
1242 declare i64 @llvm.amdgcn.sbfe.i64(i64, i32, i32) nounwind readnone
1244 define i32 @sbfe_offset_31(i32 %src, i32 %width) {
1245 ; CHECK-LABEL: @sbfe_offset_31(
1246 ; CHECK-NEXT: [[BFE:%.*]] = call i32 @llvm.amdgcn.sbfe.i32(i32 [[SRC:%.*]], i32 31, i32 [[WIDTH:%.*]])
1247 ; CHECK-NEXT: ret i32 [[BFE]]
1249 %bfe = call i32 @llvm.amdgcn.sbfe.i32(i32 %src, i32 31, i32 %width)
1253 define i32 @sbfe_neg1_5_7() {
1254 ; CHECK-LABEL: @sbfe_neg1_5_7(
1255 ; CHECK-NEXT: ret i32 -1
1257 %bfe = call i32 @llvm.amdgcn.sbfe.i32(i32 -1, i32 5, i32 7)
1261 define i64 @sbfe_offset_32_width_32_i64(i64 %src) {
1262 ; CHECK-LABEL: @sbfe_offset_32_width_32_i64(
1263 ; CHECK-NEXT: [[BFE:%.*]] = ashr i64 [[SRC:%.*]], 32
1264 ; CHECK-NEXT: ret i64 [[BFE]]
1266 %bfe = call i64 @llvm.amdgcn.sbfe.i64(i64 %src, i32 32, i32 32)
1270 ; --------------------------------------------------------------------
1272 ; --------------------------------------------------------------------
1274 declare void @llvm.amdgcn.exp.f32(i32 immarg, i32 immarg, float, float, float, float, i1 immarg, i1 immarg) nounwind inaccessiblememonly
1279 define void @exp_disabled_inputs_to_undef(float %x, float %y, float %z, float %w) {
1280 ; enable src0..src3 constants
1281 ; CHECK-LABEL: @exp_disabled_inputs_to_undef(
1282 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 1, float 1.000000e+00, float undef, float undef, float undef, i1 true, i1 false)
1283 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 2, float undef, float 2.000000e+00, float undef, float undef, i1 true, i1 false)
1284 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 4, float undef, float undef, float 5.000000e-01, float undef, i1 true, i1 false)
1285 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 8, float undef, float undef, float undef, float 4.000000e+00, i1 true, i1 false)
1286 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 1, float [[X:%.*]], float undef, float undef, float undef, i1 true, i1 false)
1287 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 2, float undef, float [[Y:%.*]], float undef, float undef, i1 true, i1 false)
1288 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 4, float undef, float undef, float [[Z:%.*]], float undef, i1 true, i1 false)
1289 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 8, float undef, float undef, float undef, float [[W:%.*]], i1 true, i1 false)
1290 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 0, float undef, float undef, float undef, float undef, i1 true, i1 false)
1291 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 3, float 1.000000e+00, float 2.000000e+00, float undef, float undef, i1 true, i1 false)
1292 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 5, float 1.000000e+00, float undef, float 5.000000e-01, float undef, i1 true, i1 false)
1293 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 9, float 1.000000e+00, float undef, float undef, float 4.000000e+00, i1 false, i1 false)
1294 ; CHECK-NEXT: call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float 1.000000e+00, float 2.000000e+00, float 5.000000e-01, float 4.000000e+00, i1 false, i1 false)
1295 ; CHECK-NEXT: ret void
1297 call void @llvm.amdgcn.exp.f32(i32 0, i32 1, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1298 call void @llvm.amdgcn.exp.f32(i32 0, i32 2, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1299 call void @llvm.amdgcn.exp.f32(i32 0, i32 4, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1300 call void @llvm.amdgcn.exp.f32(i32 0, i32 8, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1302 ; enable src0..src3 variables
1303 call void @llvm.amdgcn.exp.f32(i32 0, i32 1, float %x, float %y, float %z, float %w, i1 true, i1 false)
1304 call void @llvm.amdgcn.exp.f32(i32 0, i32 2, float %x, float %y, float %z, float %w, i1 true, i1 false)
1305 call void @llvm.amdgcn.exp.f32(i32 0, i32 4, float %x, float %y, float %z, float %w, i1 true, i1 false)
1306 call void @llvm.amdgcn.exp.f32(i32 0, i32 8, float %x, float %y, float %z, float %w, i1 true, i1 false)
1309 call void @llvm.amdgcn.exp.f32(i32 0, i32 0, float %x, float %y, float %z, float %w, i1 true, i1 false)
1311 ; enable different source combinations
1312 call void @llvm.amdgcn.exp.f32(i32 0, i32 3, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1313 call void @llvm.amdgcn.exp.f32(i32 0, i32 5, float 1.0, float 2.0, float 0.5, float 4.0, i1 true, i1 false)
1314 call void @llvm.amdgcn.exp.f32(i32 0, i32 9, float 1.0, float 2.0, float 0.5, float 4.0, i1 false, i1 false)
1315 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float 1.0, float 2.0, float 0.5, float 4.0, i1 false, i1 false)
1320 ; --------------------------------------------------------------------
1321 ; llvm.amdgcn.exp.compr
1322 ; --------------------------------------------------------------------
1324 declare void @llvm.amdgcn.exp.compr.v2f16(i32 immarg, i32 immarg, <2 x half>, <2 x half>, i1 immarg, i1 immarg) nounwind inaccessiblememonly
1328 define void @exp_compr_disabled_inputs_to_undef(<2 x half> %xy, <2 x half> %zw) {
1329 ; CHECK-LABEL: @exp_compr_disabled_inputs_to_undef(
1330 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 0, <2 x half> undef, <2 x half> undef, i1 true, i1 false)
1331 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 1, <2 x half> <half 0xH3C00, half 0xH4000>, <2 x half> undef, i1 true, i1 false)
1332 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 2, <2 x half> <half 0xH3C00, half 0xH4000>, <2 x half> undef, i1 true, i1 false)
1333 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 3, <2 x half> <half 0xH3C00, half 0xH4000>, <2 x half> undef, i1 true, i1 false)
1334 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 0, <2 x half> undef, <2 x half> undef, i1 true, i1 false)
1335 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 1, <2 x half> [[XY:%.*]], <2 x half> undef, i1 true, i1 false)
1336 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 2, <2 x half> [[XY]], <2 x half> undef, i1 true, i1 false)
1337 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 3, <2 x half> [[XY]], <2 x half> undef, i1 true, i1 false)
1338 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 12, <2 x half> undef, <2 x half> [[ZW:%.*]], i1 true, i1 false)
1339 ; CHECK-NEXT: call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 15, <2 x half> [[XY]], <2 x half> [[ZW]], i1 true, i1 false)
1340 ; CHECK-NEXT: ret void
1342 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 0, <2 x half> <half 1.0, half 2.0>, <2 x half> <half 0.5, half 4.0>, i1 true, i1 false)
1343 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 1, <2 x half> <half 1.0, half 2.0>, <2 x half> <half 0.5, half 4.0>, i1 true, i1 false)
1344 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 2, <2 x half> <half 1.0, half 2.0>, <2 x half> <half 0.5, half 4.0>, i1 true, i1 false)
1345 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 3, <2 x half> <half 1.0, half 2.0>, <2 x half> <half 0.5, half 4.0>, i1 true, i1 false)
1347 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 0, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1348 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 1, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1349 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 2, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1350 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 3, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1352 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 12, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1353 call void @llvm.amdgcn.exp.compr.v2f16(i32 0, i32 15, <2 x half> %xy, <2 x half> %zw, i1 true, i1 false)
1357 ; --------------------------------------------------------------------
1359 ; --------------------------------------------------------------------
1361 declare float @llvm.amdgcn.fmed3.f32(float, float, float) nounwind readnone
1363 define float @fmed3_f32(float %x, float %y, float %z) {
1364 ; CHECK-LABEL: @fmed3_f32(
1365 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
1366 ; CHECK-NEXT: ret float [[MED3]]
1368 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float %y, float %z)
1372 define float @fmed3_canonicalize_x_c0_c1_f32(float %x) {
1373 ; CHECK-LABEL: @fmed3_canonicalize_x_c0_c1_f32(
1374 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float 0.000000e+00, float 1.000000e+00)
1375 ; CHECK-NEXT: ret float [[MED3]]
1377 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float 0.0, float 1.0)
1381 define float @fmed3_canonicalize_c0_x_c1_f32(float %x) {
1382 ; CHECK-LABEL: @fmed3_canonicalize_c0_x_c1_f32(
1383 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float 0.000000e+00, float 1.000000e+00)
1384 ; CHECK-NEXT: ret float [[MED3]]
1386 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0.0, float %x, float 1.0)
1390 define float @fmed3_canonicalize_c0_c1_x_f32(float %x) {
1391 ; CHECK-LABEL: @fmed3_canonicalize_c0_c1_x_f32(
1392 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float 0.000000e+00, float 1.000000e+00)
1393 ; CHECK-NEXT: ret float [[MED3]]
1395 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0.0, float 1.0, float %x)
1399 define float @fmed3_canonicalize_x_y_c_f32(float %x, float %y) {
1400 ; CHECK-LABEL: @fmed3_canonicalize_x_y_c_f32(
1401 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
1402 ; CHECK-NEXT: ret float [[MED3]]
1404 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float %y, float 1.0)
1408 define float @fmed3_canonicalize_x_c_y_f32(float %x, float %y) {
1409 ; CHECK-LABEL: @fmed3_canonicalize_x_c_y_f32(
1410 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
1411 ; CHECK-NEXT: ret float [[MED3]]
1413 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float 1.0, float %y)
1417 define float @fmed3_canonicalize_c_x_y_f32(float %x, float %y) {
1418 ; CHECK-LABEL: @fmed3_canonicalize_c_x_y_f32(
1419 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.amdgcn.fmed3.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
1420 ; CHECK-NEXT: ret float [[MED3]]
1422 %med3 = call float @llvm.amdgcn.fmed3.f32(float 1.0, float %x, float %y)
1426 define float @fmed3_undef_x_y_f32(float %x, float %y) {
1427 ; CHECK-LABEL: @fmed3_undef_x_y_f32(
1428 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1429 ; CHECK-NEXT: ret float [[MED3]]
1431 %med3 = call float @llvm.amdgcn.fmed3.f32(float undef, float %x, float %y)
1435 define float @fmed3_fmf_undef_x_y_f32(float %x, float %y) {
1436 ; CHECK-LABEL: @fmed3_fmf_undef_x_y_f32(
1437 ; CHECK-NEXT: [[MED3:%.*]] = call nnan float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1438 ; CHECK-NEXT: ret float [[MED3]]
1440 %med3 = call nnan float @llvm.amdgcn.fmed3.f32(float undef, float %x, float %y)
1444 define float @fmed3_x_undef_y_f32(float %x, float %y) {
1445 ; CHECK-LABEL: @fmed3_x_undef_y_f32(
1446 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1447 ; CHECK-NEXT: ret float [[MED3]]
1449 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float undef, float %y)
1453 define float @fmed3_x_y_undef_f32(float %x, float %y) {
1454 ; CHECK-LABEL: @fmed3_x_y_undef_f32(
1455 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
1456 ; CHECK-NEXT: ret float [[MED3]]
1458 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float %y, float undef)
1462 define float @fmed3_qnan0_x_y_f32(float %x, float %y) {
1463 ; CHECK-LABEL: @fmed3_qnan0_x_y_f32(
1464 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1465 ; CHECK-NEXT: ret float [[MED3]]
1467 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8000000000000, float %x, float %y)
1471 define float @fmed3_x_qnan0_y_f32(float %x, float %y) {
1472 ; CHECK-LABEL: @fmed3_x_qnan0_y_f32(
1473 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1474 ; CHECK-NEXT: ret float [[MED3]]
1476 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float 0x7FF8000000000000, float %y)
1480 define float @fmed3_x_y_qnan0_f32(float %x, float %y) {
1481 ; CHECK-LABEL: @fmed3_x_y_qnan0_f32(
1482 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
1483 ; CHECK-NEXT: ret float [[MED3]]
1485 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float %y, float 0x7FF8000000000000)
1489 define float @fmed3_qnan1_x_y_f32(float %x, float %y) {
1490 ; CHECK-LABEL: @fmed3_qnan1_x_y_f32(
1491 ; CHECK-NEXT: [[MED3:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1492 ; CHECK-NEXT: ret float [[MED3]]
1494 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8000100000000, float %x, float %y)
1498 ; This can return any of the qnans.
1499 define float @fmed3_qnan0_qnan1_qnan2_f32(float %x, float %y) {
1500 ; CHECK-LABEL: @fmed3_qnan0_qnan1_qnan2_f32(
1501 ; CHECK-NEXT: ret float 0x7FF8030000000000
1503 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8000100000000, float 0x7FF8002000000000, float 0x7FF8030000000000)
1507 define float @fmed3_constant_src0_0_f32(float %x, float %y) {
1508 ; CHECK-LABEL: @fmed3_constant_src0_0_f32(
1509 ; CHECK-NEXT: ret float 5.000000e-01
1511 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0.5, float -1.0, float 4.0)
1515 define float @fmed3_constant_src0_1_f32(float %x, float %y) {
1516 ; CHECK-LABEL: @fmed3_constant_src0_1_f32(
1517 ; CHECK-NEXT: ret float 5.000000e-01
1519 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0.5, float 4.0, float -1.0)
1523 define float @fmed3_constant_src1_0_f32(float %x, float %y) {
1524 ; CHECK-LABEL: @fmed3_constant_src1_0_f32(
1525 ; CHECK-NEXT: ret float 5.000000e-01
1527 %med3 = call float @llvm.amdgcn.fmed3.f32(float -1.0, float 0.5, float 4.0)
1531 define float @fmed3_constant_src1_1_f32(float %x, float %y) {
1532 ; CHECK-LABEL: @fmed3_constant_src1_1_f32(
1533 ; CHECK-NEXT: ret float 5.000000e-01
1535 %med3 = call float @llvm.amdgcn.fmed3.f32(float 4.0, float 0.5, float -1.0)
1539 define float @fmed3_constant_src2_0_f32(float %x, float %y) {
1540 ; CHECK-LABEL: @fmed3_constant_src2_0_f32(
1541 ; CHECK-NEXT: ret float 5.000000e-01
1543 %med3 = call float @llvm.amdgcn.fmed3.f32(float -1.0, float 4.0, float 0.5)
1547 define float @fmed3_constant_src2_1_f32(float %x, float %y) {
1548 ; CHECK-LABEL: @fmed3_constant_src2_1_f32(
1549 ; CHECK-NEXT: ret float 5.000000e-01
1551 %med3 = call float @llvm.amdgcn.fmed3.f32(float 4.0, float -1.0, float 0.5)
1555 define float @fmed3_x_qnan0_qnan1_f32(float %x) {
1556 ; CHECK-LABEL: @fmed3_x_qnan0_qnan1_f32(
1557 ; CHECK-NEXT: ret float [[X:%.*]]
1559 %med3 = call float @llvm.amdgcn.fmed3.f32(float %x, float 0x7FF8001000000000, float 0x7FF8002000000000)
1563 define float @fmed3_qnan0_x_qnan1_f32(float %x) {
1564 ; CHECK-LABEL: @fmed3_qnan0_x_qnan1_f32(
1565 ; CHECK-NEXT: ret float [[X:%.*]]
1567 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8001000000000, float %x, float 0x7FF8002000000000)
1571 define float @fmed3_qnan0_qnan1_x_f32(float %x) {
1572 ; CHECK-LABEL: @fmed3_qnan0_qnan1_x_f32(
1573 ; CHECK-NEXT: ret float [[X:%.*]]
1575 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8001000000000, float 0x7FF8002000000000, float %x)
1579 define float @fmed3_nan_0_1_f32() {
1580 ; CHECK-LABEL: @fmed3_nan_0_1_f32(
1581 ; CHECK-NEXT: ret float 0.000000e+00
1583 %med3 = call float @llvm.amdgcn.fmed3.f32(float 0x7FF8001000000000, float 0.0, float 1.0)
1587 define float @fmed3_0_nan_1_f32() {
1588 ; CHECK-LABEL: @fmed3_0_nan_1_f32(
1589 ; CHECK-NEXT: ret float 0.000000e+00
1591 %med = call float @llvm.amdgcn.fmed3.f32(float 0.0, float 0x7FF8001000000000, float 1.0)
1595 define float @fmed3_0_1_nan_f32() {
1596 ; CHECK-LABEL: @fmed3_0_1_nan_f32(
1597 ; CHECK-NEXT: ret float 1.000000e+00
1599 %med = call float @llvm.amdgcn.fmed3.f32(float 0.0, float 1.0, float 0x7FF8001000000000)
1603 define float @fmed3_undef_0_1_f32() {
1604 ; CHECK-LABEL: @fmed3_undef_0_1_f32(
1605 ; CHECK-NEXT: ret float 0.000000e+00
1607 %med3 = call float @llvm.amdgcn.fmed3.f32(float undef, float 0.0, float 1.0)
1611 define float @fmed3_0_undef_1_f32() {
1612 ; CHECK-LABEL: @fmed3_0_undef_1_f32(
1613 ; CHECK-NEXT: ret float 0.000000e+00
1615 %med = call float @llvm.amdgcn.fmed3.f32(float 0.0, float undef, float 1.0)
1619 define float @fmed3_0_1_undef_f32() {
1620 ; CHECK-LABEL: @fmed3_0_1_undef_f32(
1621 ; CHECK-NEXT: ret float 1.000000e+00
1623 %med = call float @llvm.amdgcn.fmed3.f32(float 0.0, float 1.0, float undef)
1627 ; --------------------------------------------------------------------
1629 ; --------------------------------------------------------------------
1631 declare i64 @llvm.amdgcn.icmp.i64.i32(i32, i32, i32 immarg) nounwind readnone convergent
1632 declare i64 @llvm.amdgcn.icmp.i64.i64(i64, i64, i32 immarg) nounwind readnone convergent
1633 declare i64 @llvm.amdgcn.icmp.i64.i1(i1, i1, i32 immarg) nounwind readnone convergent
1635 define i64 @invalid_icmp_code(i32 %a, i32 %b) {
1636 ; CHECK-LABEL: @invalid_icmp_code(
1637 ; CHECK-NEXT: [[UNDER:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 31)
1638 ; CHECK-NEXT: [[OVER:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A]], i32 [[B]], i32 42)
1639 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[UNDER]], [[OVER]]
1640 ; CHECK-NEXT: ret i64 [[OR]]
1642 %under = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %a, i32 %b, i32 31)
1643 %over = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %a, i32 %b, i32 42)
1644 %or = or i64 %under, %over
1648 define i64 @icmp_constant_inputs_false() {
1649 ; CHECK-LABEL: @icmp_constant_inputs_false(
1650 ; CHECK-NEXT: ret i64 0
1652 %result = call i64 @llvm.amdgcn.icmp.i64.i32(i32 9, i32 8, i32 32)
1656 define i64 @icmp_constant_inputs_true() {
1657 ; CHECK-LABEL: @icmp_constant_inputs_true(
1658 ; CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.read_register.i64(metadata !0) [[CONVERGENT:#[0-9]*]]
1659 ; CHECK-NEXT: ret i64 [[RESULT]]
1661 %result = call i64 @llvm.amdgcn.icmp.i64.i32(i32 9, i32 8, i32 34)
1665 define i64 @icmp_constant_to_rhs_slt(i32 %x) {
1666 ; CHECK-LABEL: @icmp_constant_to_rhs_slt(
1667 ; CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[X:%.*]], i32 9, i32 38)
1668 ; CHECK-NEXT: ret i64 [[RESULT]]
1670 %result = call i64 @llvm.amdgcn.icmp.i64.i32(i32 9, i32 %x, i32 40)
1674 define i64 @fold_icmp_ne_0_zext_icmp_eq_i32(i32 %a, i32 %b) {
1675 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i32(
1676 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 32)
1677 ; CHECK-NEXT: ret i64 [[MASK]]
1679 %cmp = icmp eq i32 %a, %b
1680 %zext.cmp = zext i1 %cmp to i32
1681 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1685 define i64 @fold_icmp_ne_0_zext_icmp_ne_i32(i32 %a, i32 %b) {
1686 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ne_i32(
1687 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 33)
1688 ; CHECK-NEXT: ret i64 [[MASK]]
1690 %cmp = icmp ne i32 %a, %b
1691 %zext.cmp = zext i1 %cmp to i32
1692 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1696 define i64 @fold_icmp_ne_0_zext_icmp_sle_i32(i32 %a, i32 %b) {
1697 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_sle_i32(
1698 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 41)
1699 ; CHECK-NEXT: ret i64 [[MASK]]
1701 %cmp = icmp sle i32 %a, %b
1702 %zext.cmp = zext i1 %cmp to i32
1703 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1707 define i64 @fold_icmp_ne_0_zext_icmp_ugt_i64(i64 %a, i64 %b) {
1708 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ugt_i64(
1709 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i64(i64 [[A:%.*]], i64 [[B:%.*]], i32 34)
1710 ; CHECK-NEXT: ret i64 [[MASK]]
1712 %cmp = icmp ugt i64 %a, %b
1713 %zext.cmp = zext i1 %cmp to i32
1714 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1718 define i64 @fold_icmp_ne_0_zext_icmp_ult_swap_i64(i64 %a, i64 %b) {
1719 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ult_swap_i64(
1720 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i64(i64 [[A:%.*]], i64 [[B:%.*]], i32 34)
1721 ; CHECK-NEXT: ret i64 [[MASK]]
1723 %cmp = icmp ugt i64 %a, %b
1724 %zext.cmp = zext i1 %cmp to i32
1725 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 0, i32 %zext.cmp, i32 33)
1729 define i64 @fold_icmp_ne_0_zext_fcmp_oeq_f32(float %a, float %b) {
1730 ; CHECK-LABEL: @fold_icmp_ne_0_zext_fcmp_oeq_f32(
1731 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 1)
1732 ; CHECK-NEXT: ret i64 [[MASK]]
1734 %cmp = fcmp oeq float %a, %b
1735 %zext.cmp = zext i1 %cmp to i32
1736 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1740 define i64 @fold_icmp_ne_0_zext_fcmp_une_f32(float %a, float %b) {
1741 ; CHECK-LABEL: @fold_icmp_ne_0_zext_fcmp_une_f32(
1742 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 14)
1743 ; CHECK-NEXT: ret i64 [[MASK]]
1745 %cmp = fcmp une float %a, %b
1746 %zext.cmp = zext i1 %cmp to i32
1747 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1751 define i64 @fold_icmp_ne_0_zext_fcmp_olt_f64(double %a, double %b) {
1752 ; CHECK-LABEL: @fold_icmp_ne_0_zext_fcmp_olt_f64(
1753 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f64(double [[A:%.*]], double [[B:%.*]], i32 4)
1754 ; CHECK-NEXT: ret i64 [[MASK]]
1756 %cmp = fcmp olt double %a, %b
1757 %zext.cmp = zext i1 %cmp to i32
1758 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1762 define i64 @fold_icmp_sext_icmp_ne_0_i32(i32 %a, i32 %b) {
1763 ; CHECK-LABEL: @fold_icmp_sext_icmp_ne_0_i32(
1764 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 32)
1765 ; CHECK-NEXT: ret i64 [[MASK]]
1767 %cmp = icmp eq i32 %a, %b
1768 %sext.cmp = sext i1 %cmp to i32
1769 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cmp, i32 0, i32 33)
1773 define i64 @fold_icmp_eq_0_zext_icmp_eq_i32(i32 %a, i32 %b) {
1774 ; CHECK-LABEL: @fold_icmp_eq_0_zext_icmp_eq_i32(
1775 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 33)
1776 ; CHECK-NEXT: ret i64 [[MASK]]
1778 %cmp = icmp eq i32 %a, %b
1779 %zext.cmp = zext i1 %cmp to i32
1780 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 32)
1784 define i64 @fold_icmp_eq_0_zext_icmp_slt_i32(i32 %a, i32 %b) {
1785 ; CHECK-LABEL: @fold_icmp_eq_0_zext_icmp_slt_i32(
1786 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 39)
1787 ; CHECK-NEXT: ret i64 [[MASK]]
1789 %cmp = icmp slt i32 %a, %b
1790 %zext.cmp = zext i1 %cmp to i32
1791 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 32)
1795 define i64 @fold_icmp_eq_0_zext_fcmp_oeq_f32(float %a, float %b) {
1796 ; CHECK-LABEL: @fold_icmp_eq_0_zext_fcmp_oeq_f32(
1797 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 14)
1798 ; CHECK-NEXT: ret i64 [[MASK]]
1800 %cmp = fcmp oeq float %a, %b
1801 %zext.cmp = zext i1 %cmp to i32
1802 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 32)
1806 define i64 @fold_icmp_eq_0_zext_fcmp_ule_f32(float %a, float %b) {
1807 ; CHECK-LABEL: @fold_icmp_eq_0_zext_fcmp_ule_f32(
1808 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 2)
1809 ; CHECK-NEXT: ret i64 [[MASK]]
1811 %cmp = fcmp ule float %a, %b
1812 %zext.cmp = zext i1 %cmp to i32
1813 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 32)
1817 define i64 @fold_icmp_eq_0_zext_fcmp_ogt_f32(float %a, float %b) {
1818 ; CHECK-LABEL: @fold_icmp_eq_0_zext_fcmp_ogt_f32(
1819 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 13)
1820 ; CHECK-NEXT: ret i64 [[MASK]]
1822 %cmp = fcmp ogt float %a, %b
1823 %zext.cmp = zext i1 %cmp to i32
1824 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 32)
1828 define i64 @fold_icmp_zext_icmp_eq_1_i32(i32 %a, i32 %b) {
1829 ; CHECK-LABEL: @fold_icmp_zext_icmp_eq_1_i32(
1830 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 32)
1831 ; CHECK-NEXT: ret i64 [[MASK]]
1833 %cmp = icmp eq i32 %a, %b
1834 %zext.cmp = zext i1 %cmp to i32
1835 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 1, i32 32)
1839 define i64 @fold_icmp_zext_argi1_eq_1_i32(i1 %cond) {
1840 ; CHECK-LABEL: @fold_icmp_zext_argi1_eq_1_i32(
1841 ; CHECK-NEXT: [[ZEXT_COND:%.*]] = zext i1 [[COND:%.*]] to i32
1842 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[ZEXT_COND]], i32 0, i32 33)
1843 ; CHECK-NEXT: ret i64 [[MASK]]
1845 %zext.cond = zext i1 %cond to i32
1846 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cond, i32 1, i32 32)
1850 define i64 @fold_icmp_zext_argi1_eq_neg1_i32(i1 %cond) {
1851 ; CHECK-LABEL: @fold_icmp_zext_argi1_eq_neg1_i32(
1852 ; CHECK-NEXT: [[ZEXT_COND:%.*]] = zext i1 [[COND:%.*]] to i32
1853 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[ZEXT_COND]], i32 -1, i32 32)
1854 ; CHECK-NEXT: ret i64 [[MASK]]
1856 %zext.cond = zext i1 %cond to i32
1857 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cond, i32 -1, i32 32)
1861 define i64 @fold_icmp_sext_argi1_eq_1_i32(i1 %cond) {
1862 ; CHECK-LABEL: @fold_icmp_sext_argi1_eq_1_i32(
1863 ; CHECK-NEXT: [[SEXT_COND:%.*]] = sext i1 [[COND:%.*]] to i32
1864 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[SEXT_COND]], i32 1, i32 32)
1865 ; CHECK-NEXT: ret i64 [[MASK]]
1867 %sext.cond = sext i1 %cond to i32
1868 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cond, i32 1, i32 32)
1872 define i64 @fold_icmp_sext_argi1_eq_neg1_i32(i1 %cond) {
1873 ; CHECK-LABEL: @fold_icmp_sext_argi1_eq_neg1_i32(
1874 ; CHECK-NEXT: [[SEXT_COND:%.*]] = sext i1 [[COND:%.*]] to i32
1875 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[SEXT_COND]], i32 0, i32 33)
1876 ; CHECK-NEXT: ret i64 [[MASK]]
1878 %sext.cond = sext i1 %cond to i32
1879 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cond, i32 -1, i32 32)
1883 define i64 @fold_icmp_sext_argi1_eq_neg1_i64(i1 %cond) {
1884 ; CHECK-LABEL: @fold_icmp_sext_argi1_eq_neg1_i64(
1885 ; CHECK-NEXT: [[SEXT_COND:%.*]] = sext i1 [[COND:%.*]] to i64
1886 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i64(i64 [[SEXT_COND]], i64 0, i32 33)
1887 ; CHECK-NEXT: ret i64 [[MASK]]
1889 %sext.cond = sext i1 %cond to i64
1890 %mask = call i64 @llvm.amdgcn.icmp.i64.i64(i64 %sext.cond, i64 -1, i32 32)
1894 ; TODO: Should be able to fold to false
1895 define i64 @fold_icmp_sext_icmp_eq_1_i32(i32 %a, i32 %b) {
1896 ; CHECK-LABEL: @fold_icmp_sext_icmp_eq_1_i32(
1897 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
1898 ; CHECK-NEXT: [[SEXT_CMP:%.*]] = sext i1 [[CMP]] to i32
1899 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[SEXT_CMP]], i32 1, i32 32)
1900 ; CHECK-NEXT: ret i64 [[MASK]]
1902 %cmp = icmp eq i32 %a, %b
1903 %sext.cmp = sext i1 %cmp to i32
1904 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cmp, i32 1, i32 32)
1908 define i64 @fold_icmp_sext_icmp_eq_neg1_i32(i32 %a, i32 %b) {
1909 ; CHECK-LABEL: @fold_icmp_sext_icmp_eq_neg1_i32(
1910 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 32)
1911 ; CHECK-NEXT: ret i64 [[MASK]]
1913 %cmp = icmp eq i32 %a, %b
1914 %sext.cmp = sext i1 %cmp to i32
1915 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cmp, i32 -1, i32 32)
1919 define i64 @fold_icmp_sext_icmp_sge_neg1_i32(i32 %a, i32 %b) {
1920 ; CHECK-LABEL: @fold_icmp_sext_icmp_sge_neg1_i32(
1921 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 39)
1922 ; CHECK-NEXT: ret i64 [[MASK]]
1924 %cmp = icmp sge i32 %a, %b
1925 %sext.cmp = sext i1 %cmp to i32
1926 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %sext.cmp, i32 -1, i32 32)
1930 define i64 @fold_not_icmp_ne_0_zext_icmp_sle_i32(i32 %a, i32 %b) {
1931 ; CHECK-LABEL: @fold_not_icmp_ne_0_zext_icmp_sle_i32(
1932 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[A:%.*]], i32 [[B:%.*]], i32 38)
1933 ; CHECK-NEXT: ret i64 [[MASK]]
1935 %cmp = icmp sle i32 %a, %b
1936 %not = xor i1 %cmp, true
1937 %zext.cmp = zext i1 %not to i32
1938 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1942 define i64 @fold_icmp_ne_0_zext_icmp_eq_i4(i4 %a, i4 %b) {
1943 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i4(
1944 ; CHECK-NEXT: [[TMP1:%.*]] = zext i4 [[A:%.*]] to i16
1945 ; CHECK-NEXT: [[TMP2:%.*]] = zext i4 [[B:%.*]] to i16
1946 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 32)
1947 ; CHECK-NEXT: ret i64 [[MASK]]
1949 %cmp = icmp eq i4 %a, %b
1950 %zext.cmp = zext i1 %cmp to i32
1951 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1955 define i64 @fold_icmp_ne_0_zext_icmp_eq_i8(i8 %a, i8 %b) {
1956 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i8(
1957 ; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[A:%.*]] to i16
1958 ; CHECK-NEXT: [[TMP2:%.*]] = zext i8 [[B:%.*]] to i16
1959 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 32)
1960 ; CHECK-NEXT: ret i64 [[MASK]]
1962 %cmp = icmp eq i8 %a, %b
1963 %zext.cmp = zext i1 %cmp to i32
1964 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1968 define i64 @fold_icmp_ne_0_zext_icmp_eq_i16(i16 %a, i16 %b) {
1969 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i16(
1970 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[A:%.*]], i16 [[B:%.*]], i32 32)
1971 ; CHECK-NEXT: ret i64 [[MASK]]
1973 %cmp = icmp eq i16 %a, %b
1974 %zext.cmp = zext i1 %cmp to i32
1975 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1979 define i64 @fold_icmp_ne_0_zext_icmp_eq_i36(i36 %a, i36 %b) {
1980 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i36(
1981 ; CHECK-NEXT: [[TMP1:%.*]] = zext i36 [[A:%.*]] to i64
1982 ; CHECK-NEXT: [[TMP2:%.*]] = zext i36 [[B:%.*]] to i64
1983 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i64(i64 [[TMP1]], i64 [[TMP2]], i32 32)
1984 ; CHECK-NEXT: ret i64 [[MASK]]
1986 %cmp = icmp eq i36 %a, %b
1987 %zext.cmp = zext i1 %cmp to i32
1988 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
1992 define i64 @fold_icmp_ne_0_zext_icmp_eq_i128(i128 %a, i128 %b) {
1993 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_eq_i128(
1994 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i128 [[A:%.*]], [[B:%.*]]
1995 ; CHECK-NEXT: [[ZEXT_CMP:%.*]] = zext i1 [[CMP]] to i32
1996 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[ZEXT_CMP]], i32 0, i32 33)
1997 ; CHECK-NEXT: ret i64 [[MASK]]
1999 %cmp = icmp eq i128 %a, %b
2000 %zext.cmp = zext i1 %cmp to i32
2001 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2005 define i64 @fold_icmp_ne_0_zext_fcmp_oeq_f16(half %a, half %b) {
2006 ; CHECK-LABEL: @fold_icmp_ne_0_zext_fcmp_oeq_f16(
2007 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f16(half [[A:%.*]], half [[B:%.*]], i32 1)
2008 ; CHECK-NEXT: ret i64 [[MASK]]
2010 %cmp = fcmp oeq half %a, %b
2011 %zext.cmp = zext i1 %cmp to i32
2012 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2016 define i64 @fold_icmp_ne_0_zext_fcmp_oeq_f128(fp128 %a, fp128 %b) {
2017 ; CHECK-LABEL: @fold_icmp_ne_0_zext_fcmp_oeq_f128(
2018 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq fp128 [[A:%.*]], [[B:%.*]]
2019 ; CHECK-NEXT: [[ZEXT_CMP:%.*]] = zext i1 [[CMP]] to i32
2020 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i32(i32 [[ZEXT_CMP]], i32 0, i32 33)
2021 ; CHECK-NEXT: ret i64 [[MASK]]
2023 %cmp = fcmp oeq fp128 %a, %b
2024 %zext.cmp = zext i1 %cmp to i32
2025 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2029 define i64 @fold_icmp_ne_0_zext_icmp_slt_i4(i4 %a, i4 %b) {
2030 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_slt_i4(
2031 ; CHECK-NEXT: [[TMP1:%.*]] = sext i4 [[A:%.*]] to i16
2032 ; CHECK-NEXT: [[TMP2:%.*]] = sext i4 [[B:%.*]] to i16
2033 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 40)
2034 ; CHECK-NEXT: ret i64 [[MASK]]
2036 %cmp = icmp slt i4 %a, %b
2037 %zext.cmp = zext i1 %cmp to i32
2038 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2042 define i64 @fold_icmp_ne_0_zext_icmp_slt_i8(i8 %a, i8 %b) {
2043 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_slt_i8(
2044 ; CHECK-NEXT: [[TMP1:%.*]] = sext i8 [[A:%.*]] to i16
2045 ; CHECK-NEXT: [[TMP2:%.*]] = sext i8 [[B:%.*]] to i16
2046 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 40)
2047 ; CHECK-NEXT: ret i64 [[MASK]]
2049 %cmp = icmp slt i8 %a, %b
2050 %zext.cmp = zext i1 %cmp to i32
2051 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2055 define i64 @fold_icmp_ne_0_zext_icmp_slt_i16(i16 %a, i16 %b) {
2056 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_slt_i16(
2057 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[A:%.*]], i16 [[B:%.*]], i32 40)
2058 ; CHECK-NEXT: ret i64 [[MASK]]
2060 %cmp = icmp slt i16 %a, %b
2061 %zext.cmp = zext i1 %cmp to i32
2062 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2066 define i64 @fold_icmp_ne_0_zext_icmp_ult_i4(i4 %a, i4 %b) {
2067 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ult_i4(
2068 ; CHECK-NEXT: [[TMP1:%.*]] = zext i4 [[A:%.*]] to i16
2069 ; CHECK-NEXT: [[TMP2:%.*]] = zext i4 [[B:%.*]] to i16
2070 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 36)
2071 ; CHECK-NEXT: ret i64 [[MASK]]
2073 %cmp = icmp ult i4 %a, %b
2074 %zext.cmp = zext i1 %cmp to i32
2075 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2079 define i64 @fold_icmp_ne_0_zext_icmp_ult_i8(i8 %a, i8 %b) {
2080 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ult_i8(
2081 ; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[A:%.*]] to i16
2082 ; CHECK-NEXT: [[TMP2:%.*]] = zext i8 [[B:%.*]] to i16
2083 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[TMP1]], i16 [[TMP2]], i32 36)
2084 ; CHECK-NEXT: ret i64 [[MASK]]
2086 %cmp = icmp ult i8 %a, %b
2087 %zext.cmp = zext i1 %cmp to i32
2088 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2092 define i64 @fold_icmp_ne_0_zext_icmp_ult_i16(i16 %a, i16 %b) {
2093 ; CHECK-LABEL: @fold_icmp_ne_0_zext_icmp_ult_i16(
2094 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i16(i16 [[A:%.*]], i16 [[B:%.*]], i32 36)
2095 ; CHECK-NEXT: ret i64 [[MASK]]
2097 %cmp = icmp ult i16 %a, %b
2098 %zext.cmp = zext i1 %cmp to i32
2099 %mask = call i64 @llvm.amdgcn.icmp.i64.i32(i32 %zext.cmp, i32 0, i32 33)
2103 ; 1-bit NE comparisons
2105 define i64 @fold_icmp_i1_ne_0_icmp_eq_i1(i32 %a, i32 %b) {
2106 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i1(
2107 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
2108 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2109 ; CHECK-NEXT: ret i64 [[MASK]]
2111 %cmp = icmp eq i32 %a, %b
2112 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2116 define i64 @fold_icmp_i1_ne_0_icmp_ne_i1(i32 %a, i32 %b) {
2117 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ne_i1(
2118 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], [[B:%.*]]
2119 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2120 ; CHECK-NEXT: ret i64 [[MASK]]
2122 %cmp = icmp ne i32 %a, %b
2123 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2127 define i64 @fold_icmp_i1_ne_0_icmp_sle_i1(i32 %a, i32 %b) {
2128 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_sle_i1(
2129 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[A:%.*]], [[B:%.*]]
2130 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2131 ; CHECK-NEXT: ret i64 [[MASK]]
2133 %cmp = icmp sle i32 %a, %b
2134 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2138 define i64 @fold_icmp_i1_ne_0_icmp_ugt_i64(i64 %a, i64 %b) {
2139 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ugt_i64(
2140 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[A:%.*]], [[B:%.*]]
2141 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2142 ; CHECK-NEXT: ret i64 [[MASK]]
2144 %cmp = icmp ugt i64 %a, %b
2145 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2149 define i64 @fold_icmp_i1_ne_0_icmp_ult_swap_i64(i64 %a, i64 %b) {
2150 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ult_swap_i64(
2151 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[A:%.*]], [[B:%.*]]
2152 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2153 ; CHECK-NEXT: ret i64 [[MASK]]
2155 %cmp = icmp ugt i64 %a, %b
2156 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 false, i1 %cmp, i32 33)
2160 define i64 @fold_icmp_i1_ne_0_fcmp_oeq_f32(float %a, float %b) {
2161 ; CHECK-LABEL: @fold_icmp_i1_ne_0_fcmp_oeq_f32(
2162 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float [[A:%.*]], [[B:%.*]]
2163 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2164 ; CHECK-NEXT: ret i64 [[MASK]]
2166 %cmp = fcmp oeq float %a, %b
2167 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2171 define i64 @fold_icmp_i1_ne_0_fcmp_une_f32(float %a, float %b) {
2172 ; CHECK-LABEL: @fold_icmp_i1_ne_0_fcmp_une_f32(
2173 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une float [[A:%.*]], [[B:%.*]]
2174 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2175 ; CHECK-NEXT: ret i64 [[MASK]]
2177 %cmp = fcmp une float %a, %b
2178 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2182 define i64 @fold_icmp_i1_ne_0_fcmp_olt_f64(double %a, double %b) {
2183 ; CHECK-LABEL: @fold_icmp_i1_ne_0_fcmp_olt_f64(
2184 ; CHECK-NEXT: [[CMP:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]]
2185 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2186 ; CHECK-NEXT: ret i64 [[MASK]]
2188 %cmp = fcmp olt double %a, %b
2189 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2193 define i64 @fold_icmp_i1_ne_0_icmp_eq_i4(i4 %a, i4 %b) {
2194 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i4(
2195 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i4 [[A:%.*]], [[B:%.*]]
2196 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2197 ; CHECK-NEXT: ret i64 [[MASK]]
2199 %cmp = icmp eq i4 %a, %b
2200 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2204 define i64 @fold_icmp_i1_ne_0_icmp_eq_i8(i8 %a, i8 %b) {
2205 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i8(
2206 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]
2207 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2208 ; CHECK-NEXT: ret i64 [[MASK]]
2210 %cmp = icmp eq i8 %a, %b
2211 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2215 define i64 @fold_icmp_i1_ne_0_icmp_eq_i16(i16 %a, i16 %b) {
2216 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i16(
2217 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[A:%.*]], [[B:%.*]]
2218 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2219 ; CHECK-NEXT: ret i64 [[MASK]]
2221 %cmp = icmp eq i16 %a, %b
2222 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2226 define i64 @fold_icmp_i1_ne_0_icmp_eq_i36(i36 %a, i36 %b) {
2227 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i36(
2228 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i36 [[A:%.*]], [[B:%.*]]
2229 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2230 ; CHECK-NEXT: ret i64 [[MASK]]
2232 %cmp = icmp eq i36 %a, %b
2233 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2237 define i64 @fold_icmp_i1_ne_0_icmp_eq_i128(i128 %a, i128 %b) {
2238 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_eq_i128(
2239 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i128 [[A:%.*]], [[B:%.*]]
2240 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2241 ; CHECK-NEXT: ret i64 [[MASK]]
2243 %cmp = icmp eq i128 %a, %b
2244 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2248 define i64 @fold_icmp_i1_ne_0_fcmp_oeq_f16(half %a, half %b) {
2249 ; CHECK-LABEL: @fold_icmp_i1_ne_0_fcmp_oeq_f16(
2250 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq half [[A:%.*]], [[B:%.*]]
2251 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2252 ; CHECK-NEXT: ret i64 [[MASK]]
2254 %cmp = fcmp oeq half %a, %b
2255 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2259 define i64 @fold_icmp_i1_ne_0_fcmp_oeq_f128(fp128 %a, fp128 %b) {
2260 ; CHECK-LABEL: @fold_icmp_i1_ne_0_fcmp_oeq_f128(
2261 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq fp128 [[A:%.*]], [[B:%.*]]
2262 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2263 ; CHECK-NEXT: ret i64 [[MASK]]
2265 %cmp = fcmp oeq fp128 %a, %b
2266 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2270 define i64 @fold_icmp_i1_ne_0_icmp_slt_i4(i4 %a, i4 %b) {
2271 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_slt_i4(
2272 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i4 [[A:%.*]], [[B:%.*]]
2273 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2274 ; CHECK-NEXT: ret i64 [[MASK]]
2276 %cmp = icmp slt i4 %a, %b
2277 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2281 define i64 @fold_icmp_i1_ne_0_icmp_slt_i8(i8 %a, i8 %b) {
2282 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_slt_i8(
2283 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[A:%.*]], [[B:%.*]]
2284 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2285 ; CHECK-NEXT: ret i64 [[MASK]]
2287 %cmp = icmp slt i8 %a, %b
2288 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2292 define i64 @fold_icmp_i1_ne_0_icmp_slt_i16(i16 %a, i16 %b) {
2293 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_slt_i16(
2294 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[A:%.*]], [[B:%.*]]
2295 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2296 ; CHECK-NEXT: ret i64 [[MASK]]
2298 %cmp = icmp slt i16 %a, %b
2299 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2303 define i64 @fold_icmp_i1_ne_0_icmp_ult_i4(i4 %a, i4 %b) {
2304 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ult_i4(
2305 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i4 [[A:%.*]], [[B:%.*]]
2306 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2307 ; CHECK-NEXT: ret i64 [[MASK]]
2309 %cmp = icmp ult i4 %a, %b
2310 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2314 define i64 @fold_icmp_i1_ne_0_icmp_ult_i8(i8 %a, i8 %b) {
2315 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ult_i8(
2316 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], [[B:%.*]]
2317 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2318 ; CHECK-NEXT: ret i64 [[MASK]]
2320 %cmp = icmp ult i8 %a, %b
2321 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2325 define i64 @fold_icmp_i1_ne_0_icmp_ult_i16(i16 %a, i16 %b) {
2326 ; CHECK-LABEL: @fold_icmp_i1_ne_0_icmp_ult_i16(
2327 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[A:%.*]], [[B:%.*]]
2328 ; CHECK-NEXT: [[MASK:%.*]] = call i64 @llvm.amdgcn.icmp.i64.i1(i1 [[CMP]], i1 false, i32 33)
2329 ; CHECK-NEXT: ret i64 [[MASK]]
2331 %cmp = icmp ult i16 %a, %b
2332 %mask = call i64 @llvm.amdgcn.icmp.i64.i1(i1 %cmp, i1 false, i32 33)
2336 ; --------------------------------------------------------------------
2338 ; --------------------------------------------------------------------
2340 declare i64 @llvm.amdgcn.fcmp.i64.f32(float, float, i32 immarg) nounwind readnone convergent
2342 define i64 @invalid_fcmp_code(float %a, float %b) {
2343 ; CHECK-LABEL: @invalid_fcmp_code(
2344 ; CHECK-NEXT: [[UNDER:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A:%.*]], float [[B:%.*]], i32 -1)
2345 ; CHECK-NEXT: [[OVER:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[A]], float [[B]], i32 16)
2346 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[UNDER]], [[OVER]]
2347 ; CHECK-NEXT: ret i64 [[OR]]
2349 %under = call i64 @llvm.amdgcn.fcmp.i64.f32(float %a, float %b, i32 -1)
2350 %over = call i64 @llvm.amdgcn.fcmp.i64.f32(float %a, float %b, i32 16)
2351 %or = or i64 %under, %over
2355 define i64 @fcmp_constant_inputs_false() {
2356 ; CHECK-LABEL: @fcmp_constant_inputs_false(
2357 ; CHECK-NEXT: ret i64 0
2359 %result = call i64 @llvm.amdgcn.fcmp.i64.f32(float 2.0, float 4.0, i32 1)
2363 define i64 @fcmp_constant_inputs_true() {
2364 ; CHECK-LABEL: @fcmp_constant_inputs_true(
2365 ; CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.read_register.i64(metadata !0) [[CONVERGENT]]
2366 ; CHECK-NEXT: ret i64 [[RESULT]]
2368 %result = call i64 @llvm.amdgcn.fcmp.i64.f32(float 2.0, float 4.0, i32 4)
2372 define i64 @fcmp_constant_to_rhs_olt(float %x) {
2373 ; CHECK-LABEL: @fcmp_constant_to_rhs_olt(
2374 ; CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.amdgcn.fcmp.i64.f32(float [[X:%.*]], float 4.000000e+00, i32 2)
2375 ; CHECK-NEXT: ret i64 [[RESULT]]
2377 %result = call i64 @llvm.amdgcn.fcmp.i64.f32(float 4.0, float %x, i32 4)
2381 ; --------------------------------------------------------------------
2382 ; llvm.amdgcn.wqm.vote
2383 ; --------------------------------------------------------------------
2385 declare i1 @llvm.amdgcn.wqm.vote(i1)
2387 define float @wqm_vote_true() {
2388 ; CHECK-LABEL: @wqm_vote_true(
2389 ; CHECK-NEXT: main_body:
2390 ; CHECK-NEXT: ret float 1.000000e+00
2393 %w = call i1 @llvm.amdgcn.wqm.vote(i1 true)
2394 %r = select i1 %w, float 1.0, float 0.0
2398 define float @wqm_vote_false() {
2399 ; CHECK-LABEL: @wqm_vote_false(
2400 ; CHECK-NEXT: main_body:
2401 ; CHECK-NEXT: ret float 0.000000e+00
2404 %w = call i1 @llvm.amdgcn.wqm.vote(i1 false)
2405 %r = select i1 %w, float 1.0, float 0.0
2409 define float @wqm_vote_undef() {
2410 ; CHECK-LABEL: @wqm_vote_undef(
2411 ; CHECK-NEXT: main_body:
2412 ; CHECK-NEXT: ret float 0.000000e+00
2415 %w = call i1 @llvm.amdgcn.wqm.vote(i1 undef)
2416 %r = select i1 %w, float 1.0, float 0.0
2420 ; --------------------------------------------------------------------
2422 ; --------------------------------------------------------------------
2424 declare void @llvm.amdgcn.kill(i1)
2426 define void @kill_true() {
2427 ; CHECK-LABEL: @kill_true(
2428 ; CHECK-NEXT: ret void
2430 call void @llvm.amdgcn.kill(i1 true)
2434 ; --------------------------------------------------------------------
2435 ; llvm.amdgcn.readfirstlane
2436 ; --------------------------------------------------------------------
2438 declare i32 @llvm.amdgcn.readfirstlane(i32)
2440 @gv = constant i32 0
2442 define amdgpu_kernel void @readfirstlane_constant(i32 %arg) {
2443 ; CHECK-LABEL: @readfirstlane_constant(
2444 ; CHECK-NEXT: [[VAR:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2445 ; CHECK-NEXT: store volatile i32 [[VAR]], i32* undef, align 4
2446 ; CHECK-NEXT: store volatile i32 0, i32* undef, align 4
2447 ; CHECK-NEXT: store volatile i32 123, i32* undef, align 4
2448 ; CHECK-NEXT: store volatile i32 ptrtoint (i32* @gv to i32), i32* undef, align 4
2449 ; CHECK-NEXT: store volatile i32 undef, i32* undef, align 4
2450 ; CHECK-NEXT: ret void
2452 %var = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2453 %zero = call i32 @llvm.amdgcn.readfirstlane(i32 0)
2454 %imm = call i32 @llvm.amdgcn.readfirstlane(i32 123)
2455 %constexpr = call i32 @llvm.amdgcn.readfirstlane(i32 ptrtoint (i32* @gv to i32))
2456 %undef = call i32 @llvm.amdgcn.readfirstlane(i32 undef)
2457 store volatile i32 %var, i32* undef
2458 store volatile i32 %zero, i32* undef
2459 store volatile i32 %imm, i32* undef
2460 store volatile i32 %constexpr, i32* undef
2461 store volatile i32 %undef, i32* undef
2465 define i32 @readfirstlane_idempotent(i32 %arg) {
2466 ; CHECK-LABEL: @readfirstlane_idempotent(
2467 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2468 ; CHECK-NEXT: ret i32 [[READ0]]
2470 %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2471 %read1 = call i32 @llvm.amdgcn.readfirstlane(i32 %read0)
2472 %read2 = call i32 @llvm.amdgcn.readfirstlane(i32 %read1)
2476 define i32 @readfirstlane_readlane(i32 %arg) {
2477 ; CHECK-LABEL: @readfirstlane_readlane(
2478 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2479 ; CHECK-NEXT: ret i32 [[READ0]]
2481 %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2482 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 0)
2486 define i32 @readfirstlane_readfirstlane_different_block(i32 %arg) {
2487 ; CHECK-LABEL: @readfirstlane_readfirstlane_different_block(
2489 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2490 ; CHECK-NEXT: br label [[BB1:%.*]]
2492 ; CHECK-NEXT: [[READ1:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[READ0]])
2493 ; CHECK-NEXT: ret i32 [[READ1]]
2496 %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2500 %read1 = call i32 @llvm.amdgcn.readfirstlane(i32 %read0)
2504 define i32 @readfirstlane_readlane_different_block(i32 %arg) {
2505 ; CHECK-LABEL: @readfirstlane_readlane_different_block(
2507 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[ARG:%.*]], i32 0)
2508 ; CHECK-NEXT: br label [[BB1:%.*]]
2510 ; CHECK-NEXT: [[READ1:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[READ0]])
2511 ; CHECK-NEXT: ret i32 [[READ1]]
2514 %read0 = call i32 @llvm.amdgcn.readlane(i32 %arg, i32 0)
2518 %read1 = call i32 @llvm.amdgcn.readfirstlane(i32 %read0)
2522 ; --------------------------------------------------------------------
2523 ; llvm.amdgcn.readlane
2524 ; --------------------------------------------------------------------
2526 declare i32 @llvm.amdgcn.readlane(i32, i32)
2528 define amdgpu_kernel void @readlane_constant(i32 %arg, i32 %lane) {
2529 ; CHECK-LABEL: @readlane_constant(
2530 ; CHECK-NEXT: [[VAR:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[ARG:%.*]], i32 7)
2531 ; CHECK-NEXT: store volatile i32 [[VAR]], i32* undef, align 4
2532 ; CHECK-NEXT: store volatile i32 0, i32* undef, align 4
2533 ; CHECK-NEXT: store volatile i32 123, i32* undef, align 4
2534 ; CHECK-NEXT: store volatile i32 ptrtoint (i32* @gv to i32), i32* undef, align 4
2535 ; CHECK-NEXT: store volatile i32 undef, i32* undef, align 4
2536 ; CHECK-NEXT: ret void
2538 %var = call i32 @llvm.amdgcn.readlane(i32 %arg, i32 7)
2539 %zero = call i32 @llvm.amdgcn.readlane(i32 0, i32 %lane)
2540 %imm = call i32 @llvm.amdgcn.readlane(i32 123, i32 %lane)
2541 %constexpr = call i32 @llvm.amdgcn.readlane(i32 ptrtoint (i32* @gv to i32), i32 %lane)
2542 %undef = call i32 @llvm.amdgcn.readlane(i32 undef, i32 %lane)
2543 store volatile i32 %var, i32* undef
2544 store volatile i32 %zero, i32* undef
2545 store volatile i32 %imm, i32* undef
2546 store volatile i32 %constexpr, i32* undef
2547 store volatile i32 %undef, i32* undef
2551 define i32 @readlane_idempotent(i32 %arg, i32 %lane) {
2552 ; CHECK-LABEL: @readlane_idempotent(
2553 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[ARG:%.*]], i32 [[LANE:%.*]])
2554 ; CHECK-NEXT: ret i32 [[READ0]]
2556 %read0 = call i32 @llvm.amdgcn.readlane(i32 %arg, i32 %lane)
2557 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 %lane)
2561 define i32 @readlane_idempotent_different_lanes(i32 %arg, i32 %lane0, i32 %lane1) {
2562 ; CHECK-LABEL: @readlane_idempotent_different_lanes(
2563 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[ARG:%.*]], i32 [[LANE0:%.*]])
2564 ; CHECK-NEXT: [[READ1:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[READ0]], i32 [[LANE1:%.*]])
2565 ; CHECK-NEXT: ret i32 [[READ1]]
2567 %read0 = call i32 @llvm.amdgcn.readlane(i32 %arg, i32 %lane0)
2568 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 %lane1)
2572 define i32 @readlane_readfirstlane(i32 %arg) {
2573 ; CHECK-LABEL: @readlane_readfirstlane(
2574 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2575 ; CHECK-NEXT: ret i32 [[READ0]]
2577 %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2578 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 0)
2582 define i32 @readlane_idempotent_different_block(i32 %arg, i32 %lane) {
2583 ; CHECK-LABEL: @readlane_idempotent_different_block(
2585 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[ARG:%.*]], i32 [[LANE:%.*]])
2586 ; CHECK-NEXT: br label [[BB1:%.*]]
2588 ; CHECK-NEXT: [[READ1:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[READ0]], i32 [[LANE]])
2589 ; CHECK-NEXT: ret i32 [[READ1]]
2592 %read0 = call i32 @llvm.amdgcn.readlane(i32 %arg, i32 %lane)
2596 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 %lane)
2601 define i32 @readlane_readfirstlane_different_block(i32 %arg) {
2602 ; CHECK-LABEL: @readlane_readfirstlane_different_block(
2604 ; CHECK-NEXT: [[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
2605 ; CHECK-NEXT: br label [[BB1:%.*]]
2607 ; CHECK-NEXT: [[READ1:%.*]] = call i32 @llvm.amdgcn.readlane(i32 [[READ0]], i32 0)
2608 ; CHECK-NEXT: ret i32 [[READ1]]
2611 %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
2615 %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 0)
2619 ; --------------------------------------------------------------------
2620 ; llvm.amdgcn.update.dpp.i32
2621 ; --------------------------------------------------------------------
2623 declare i32 @llvm.amdgcn.update.dpp.i32(i32, i32, i32, i32, i32, i1)
2625 define amdgpu_kernel void @update_dpp_no_combine(i32 addrspace(1)* %out, i32 %in1, i32 %in2) {
2626 ; CHECK-LABEL: @update_dpp_no_combine(
2627 ; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.amdgcn.update.dpp.i32(i32 [[IN1:%.*]], i32 [[IN2:%.*]], i32 1, i32 1, i32 1, i1 false)
2628 ; CHECK-NEXT: store i32 [[TMP0]], i32 addrspace(1)* [[OUT:%.*]], align 4
2629 ; CHECK-NEXT: ret void
2631 %tmp0 = call i32 @llvm.amdgcn.update.dpp.i32(i32 %in1, i32 %in2, i32 1, i32 1, i32 1, i1 0)
2632 store i32 %tmp0, i32 addrspace(1)* %out
2636 define amdgpu_kernel void @update_dpp_drop_old(i32 addrspace(1)* %out, i32 %in1, i32 %in2) {
2637 ; CHECK-LABEL: @update_dpp_drop_old(
2638 ; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 [[IN2:%.*]], i32 3, i32 15, i32 15, i1 true)
2639 ; CHECK-NEXT: store i32 [[TMP0]], i32 addrspace(1)* [[OUT:%.*]], align 4
2640 ; CHECK-NEXT: ret void
2642 %tmp0 = call i32 @llvm.amdgcn.update.dpp.i32(i32 %in1, i32 %in2, i32 3, i32 15, i32 15, i1 1)
2643 store i32 %tmp0, i32 addrspace(1)* %out
2647 define amdgpu_kernel void @update_dpp_undef_old(i32 addrspace(1)* %out, i32 %in1) {
2648 ; CHECK-LABEL: @update_dpp_undef_old(
2649 ; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 [[IN1:%.*]], i32 4, i32 15, i32 15, i1 true)
2650 ; CHECK-NEXT: store i32 [[TMP0]], i32 addrspace(1)* [[OUT:%.*]], align 4
2651 ; CHECK-NEXT: ret void
2653 %tmp0 = call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %in1, i32 4, i32 15, i32 15, i1 1)
2654 store i32 %tmp0, i32 addrspace(1)* %out
2658 ; CHECK: attributes [[CONVERGENT]] = { convergent }