1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify %s | FileCheck %s
4 define float @canonicalize_zero() {
5 ; CHECK-LABEL: @canonicalize_zero(
6 ; CHECK-NEXT: ret float 0.000000e+00
8 %ret = call float @llvm.canonicalize.f32(float 0.0)
12 define float @canonicalize_negzero() {
13 ; CHECK-LABEL: @canonicalize_negzero(
14 ; CHECK-NEXT: ret float -0.000000e+00
16 %ret = call float @llvm.canonicalize.f32(float -0.0)
20 define <2 x float> @canonicalize_zero_vector() {
21 ; CHECK-LABEL: @canonicalize_zero_vector(
22 ; CHECK-NEXT: ret <2 x float> zeroinitializer
24 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> zeroinitializer)
28 define <2 x float> @canonicalize_negzero_vector() {
29 ; CHECK-LABEL: @canonicalize_negzero_vector(
30 ; CHECK-NEXT: ret <2 x float> <float -0.000000e+00, float -0.000000e+00>
32 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float -0.0, float -0.0>)
36 define <2 x float> @canonicalize_negzero_vector_partialundef() {
37 ; CHECK-LABEL: @canonicalize_negzero_vector_partialundef(
38 ; CHECK-NEXT: ret <2 x float> <float -0.000000e+00, float 0.000000e+00>
40 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float -0.0, float undef>)
44 define float @canonicalize_undef() {
45 ; CHECK-LABEL: @canonicalize_undef(
46 ; CHECK-NEXT: ret float 0.000000e+00
48 %ret = call float @llvm.canonicalize.f32(float undef)
52 define <2 x float> @canonicalize_undef_vector() {
53 ; CHECK-LABEL: @canonicalize_undef_vector(
54 ; CHECK-NEXT: ret <2 x float> zeroinitializer
56 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> undef)
60 define float @canonicalize_poison() {
61 ; CHECK-LABEL: @canonicalize_poison(
62 ; CHECK-NEXT: ret float poison
64 %ret = call float @llvm.canonicalize.f32(float poison)
68 define <2 x float> @canonicalize_poison_vector() {
69 ; CHECK-LABEL: @canonicalize_poison_vector(
70 ; CHECK-NEXT: ret <2 x float> poison
72 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> poison)
76 define float @canonicalize_denorm() {
77 ; CHECK-LABEL: @canonicalize_denorm(
78 ; CHECK-NEXT: ret float 0x380FFFFFC0000000
80 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
84 define float @canonicalize_pos_denorm_preserve_sign_output() "denormal-fp-math"="preserve-sign,ieee" {
85 ; CHECK-LABEL: @canonicalize_pos_denorm_preserve_sign_output(
86 ; CHECK-NEXT: ret float 0.000000e+00
88 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
92 define float @canonicalize_pos_denorm_preserve_sign_input() "denormal-fp-math"="ieee,preserve-sign" {
93 ; CHECK-LABEL: @canonicalize_pos_denorm_preserve_sign_input(
94 ; CHECK-NEXT: ret float 0.000000e+00
96 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
100 define float @canonicalize_neg_denorm_preserve_sign_output() "denormal-fp-math"="preserve-sign,ieee" {
101 ; CHECK-LABEL: @canonicalize_neg_denorm_preserve_sign_output(
102 ; CHECK-NEXT: ret float -0.000000e+00
104 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
108 define float @canonicalize_neg_denorm_preserve_sign_input() "denormal-fp-math"="ieee,preserve-sign" {
109 ; CHECK-LABEL: @canonicalize_neg_denorm_preserve_sign_input(
110 ; CHECK-NEXT: ret float -0.000000e+00
112 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
116 define float @canonicalize_pos_denorm_positive_zero_output() "denormal-fp-math"="positive-zero,ieee" {
117 ; CHECK-LABEL: @canonicalize_pos_denorm_positive_zero_output(
118 ; CHECK-NEXT: ret float 0.000000e+00
120 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
124 define float @canonicalize_pos_denorm_positive_zero_input() "denormal-fp-math"="ieee,positive-zero" {
125 ; CHECK-LABEL: @canonicalize_pos_denorm_positive_zero_input(
126 ; CHECK-NEXT: ret float 0.000000e+00
128 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
132 define float @canonicalize_neg_denorm_positive_zero_output() "denormal-fp-math"="positive-zero,ieee" {
133 ; CHECK-LABEL: @canonicalize_neg_denorm_positive_zero_output(
134 ; CHECK-NEXT: ret float 0.000000e+00
136 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
140 define float @canonicalize_neg_denorm_positive_zero_input() "denormal-fp-math"="ieee,positive-zero" {
141 ; CHECK-LABEL: @canonicalize_neg_denorm_positive_zero_input(
142 ; CHECK-NEXT: ret float 0.000000e+00
144 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
148 define float @canonicalize_pos_denorm_dynamic_dynamic() "denormal-fp-math"="dynamic,dynamic" {
149 ; CHECK-LABEL: @canonicalize_pos_denorm_dynamic_dynamic(
150 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x380FFFFFC0000000)
151 ; CHECK-NEXT: ret float [[RET]]
153 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
157 define float @canonicalize_neg_denorm_dynamic_dynamic() "denormal-fp-math"="dynamic,dynamic" {
158 ; CHECK-LABEL: @canonicalize_neg_denorm_dynamic_dynamic(
159 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0xB80FFFFFC0000000)
160 ; CHECK-NEXT: ret float [[RET]]
162 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
166 ; Dynamic output - cannot flush
167 define float @canonicalize_pos_denorm_dynamic_output() "denormal-fp-math"="dynamic,ieee" {
168 ; CHECK-LABEL: @canonicalize_pos_denorm_dynamic_output(
169 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x380FFFFFC0000000)
170 ; CHECK-NEXT: ret float [[RET]]
172 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
176 ; Dynamic output - cannot flush
177 define float @canonicalize_neg_denorm_dynamic_output() "denormal-fp-math"="dynamic,ieee" {
178 ; CHECK-LABEL: @canonicalize_neg_denorm_dynamic_output(
179 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0xB80FFFFFC0000000)
180 ; CHECK-NEXT: ret float [[RET]]
182 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
186 ; Dynamic input - cannot flush
187 define float @canonicalize_pos_denorm_dynamic_input() "denormal-fp-math"="ieee,dynamic" {
188 ; CHECK-LABEL: @canonicalize_pos_denorm_dynamic_input(
189 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x380FFFFFC0000000)
190 ; CHECK-NEXT: ret float [[RET]]
192 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
196 ; Dynamic input - cannot flush
197 define float @canonicalize_neg_denorm_dynamic_input() "denormal-fp-math"="ieee,dynamic" {
198 ; CHECK-LABEL: @canonicalize_neg_denorm_dynamic_input(
199 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0xB80FFFFFC0000000)
200 ; CHECK-NEXT: ret float [[RET]]
202 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
206 ; Input is flushed, can fold
207 define float @canonicalize_pos_denorm_dynamic_output_preserve_sign_input() "denormal-fp-math"="dynamic,preserve-sign" {
208 ; CHECK-LABEL: @canonicalize_pos_denorm_dynamic_output_preserve_sign_input(
209 ; CHECK-NEXT: ret float 0.000000e+00
211 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
215 ; Input is flushed, can fold
216 define float @canonicalize_neg_denorm_dynamic_output_preserve_sign_input() "denormal-fp-math"="dynamic,preserve-sign" {
217 ; CHECK-LABEL: @canonicalize_neg_denorm_dynamic_output_preserve_sign_input(
218 ; CHECK-NEXT: ret float -0.000000e+00
220 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
224 ; Output is known flushed, can fold
225 define float @canonicalize_pos_preserve_sign_output_denorm_dynamic_input() "denormal-fp-math"="preserve-sign,dynamic" {
226 ; CHECK-LABEL: @canonicalize_pos_preserve_sign_output_denorm_dynamic_input(
227 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x380FFFFFC0000000)
228 ; CHECK-NEXT: ret float [[RET]]
230 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
234 ; Output is known flushed, can fold
235 define float @canonicalize_neg_denorm_preserve_sign_output_dynamic_input() "denormal-fp-math"="preserve-sign,dynamic" {
236 ; CHECK-LABEL: @canonicalize_neg_denorm_preserve_sign_output_dynamic_input(
237 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0xB80FFFFFC0000000)
238 ; CHECK-NEXT: ret float [[RET]]
240 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
244 define float @canonicalize_inf() {
245 ; CHECK-LABEL: @canonicalize_inf(
246 ; CHECK-NEXT: ret float 0x7FF0000000000000
248 %ret = call float @llvm.canonicalize.f32(float 0x7FF0000000000000)
252 define float @canonicalize_neg_inf() {
253 ; CHECK-LABEL: @canonicalize_neg_inf(
254 ; CHECK-NEXT: ret float 0xFFF0000000000000
256 %ret = call float @llvm.canonicalize.f32(float 0xFFF0000000000000)
260 define float @canonicalize_qnan() {
261 ; CHECK-LABEL: @canonicalize_qnan(
262 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x7FF8000000000000)
263 ; CHECK-NEXT: ret float [[RET]]
265 %ret = call float @llvm.canonicalize.f32(float 0x7FF8000000000000)
269 define float @canonicalize_snan() {
270 ; CHECK-LABEL: @canonicalize_snan(
271 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x7FF0000020000000)
272 ; CHECK-NEXT: ret float [[RET]]
274 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 2139095041 to float))
278 define float @canonicalize_pos_normal() {
279 ; CHECK-LABEL: @canonicalize_pos_normal(
280 ; CHECK-NEXT: ret float 4.000000e+00
282 %ret = call float @llvm.canonicalize.f32(float 4.0)
286 define float @canonicalize_neg_normal() {
287 ; CHECK-LABEL: @canonicalize_neg_normal(
288 ; CHECK-NEXT: ret float -4.000000e+00
290 %ret = call float @llvm.canonicalize.f32(float -4.0)
294 define <2 x float> @canonicalize_pos_denorm_preserve_sign_output_mixed_vector() "denormal-fp-math"="preserve-sign,ieee" {
295 ; CHECK-LABEL: @canonicalize_pos_denorm_preserve_sign_output_mixed_vector(
296 ; CHECK-NEXT: ret <2 x float> <float 0.000000e+00, float -0.000000e+00>
298 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float bitcast (i32 8388607 to float), float bitcast (i32 -2139095041 to float)>)
302 define <2 x float> @canonicalize_pos_denorm_preserve_sign_input_mixed_vector() "denormal-fp-math"="ieee,preserve-sign" {
303 ; CHECK-LABEL: @canonicalize_pos_denorm_preserve_sign_input_mixed_vector(
304 ; CHECK-NEXT: ret <2 x float> <float -0.000000e+00, float 0.000000e+00>
306 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float bitcast (i32 -2139095041 to float), float bitcast (i32 8388607 to float)>)
310 define <2 x float> @canonicalize_pos_denorm_positive_zero_output_mixed_vector() "denormal-fp-math"="positive-zero,ieee" {
311 ; CHECK-LABEL: @canonicalize_pos_denorm_positive_zero_output_mixed_vector(
312 ; CHECK-NEXT: ret <2 x float> zeroinitializer
314 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float bitcast (i32 8388607 to float), float bitcast (i32 -2139095041 to float)>)
318 define <2 x float> @canonicalize_pos_denorm_positive_zero_input_mixed_vector() "denormal-fp-math"="ieee,positive-zero" {
319 ; CHECK-LABEL: @canonicalize_pos_denorm_positive_zero_input_mixed_vector(
320 ; CHECK-NEXT: ret <2 x float> zeroinitializer
322 %ret = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> <float bitcast (i32 -2139095041 to float), float bitcast (i32 8388607 to float)>)
326 define float @canonicalize_neg_denorm_preserve_sign_output_positive_zero_input() "denormal-fp-math"="preserve-sign,positive-zero" {
327 ; CHECK-LABEL: @canonicalize_neg_denorm_preserve_sign_output_positive_zero_input(
328 ; CHECK-NEXT: ret float 0.000000e+00
330 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
334 define float @canonicalize_neg_denorm_positive_zero_output_preserve_sign_input() "denormal-fp-math"="positive-zero,preserve-sign" {
335 ; CHECK-LABEL: @canonicalize_neg_denorm_positive_zero_output_preserve_sign_input(
336 ; CHECK-NEXT: ret float -0.000000e+00
338 %ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
342 ; --------------------------------------------------------------------
344 ; --------------------------------------------------------------------
346 define double @canonicalize_zero_f64() {
347 ; CHECK-LABEL: @canonicalize_zero_f64(
348 ; CHECK-NEXT: ret double 0.000000e+00
350 %ret = call double @llvm.canonicalize.f64(double 0.0)
354 define double @canonicalize_negzero_f64() {
355 ; CHECK-LABEL: @canonicalize_negzero_f64(
356 ; CHECK-NEXT: ret double -0.000000e+00
358 %ret = call double @llvm.canonicalize.f64(double -0.0)
362 define double @canonicalize_1.0_f64() {
363 ; CHECK-LABEL: @canonicalize_1.0_f64(
364 ; CHECK-NEXT: ret double 1.000000e+00
366 %ret = call double @llvm.canonicalize.f64(double 1.0)
370 define double @canonicalize_0x00000000000001_f64() {
371 ; CHECK-LABEL: @canonicalize_0x00000000000001_f64(
372 ; CHECK-NEXT: ret double 4.940660e-324
374 %ret = call double @llvm.canonicalize.f64(double 0x00000000000001)
378 define double @canonicalize_inf_f64() {
379 ; CHECK-LABEL: @canonicalize_inf_f64(
380 ; CHECK-NEXT: ret double 0x7FF0000000000000
382 %ret = call double @llvm.canonicalize.f64(double 0x7FF0000000000000)
386 define double @canonicalize_ninf_f64() {
387 ; CHECK-LABEL: @canonicalize_ninf_f64(
388 ; CHECK-NEXT: ret double 0xFFF0000000000000
390 %ret = call double @llvm.canonicalize.f64(double 0xFFF0000000000000)
394 ; --------------------------------------------------------------------
396 ; --------------------------------------------------------------------
398 define half @canonicalize_zero_f16() {
399 ; CHECK-LABEL: @canonicalize_zero_f16(
400 ; CHECK-NEXT: ret half 0xH0000
402 %ret = call half @llvm.canonicalize.f16(half 0.0)
406 define half @canonicalize_1.0_f16() {
407 ; CHECK-LABEL: @canonicalize_1.0_f16(
408 ; CHECK-NEXT: ret half 0xH3C00
410 %ret = call half @llvm.canonicalize.f16(half 1.0)
414 define half @canonicalize_0x0001_f16() {
415 ; CHECK-LABEL: @canonicalize_0x0001_f16(
416 ; CHECK-NEXT: ret half 0xH0001
418 %ret = call half @llvm.canonicalize.f16(half 0xH0001)
422 define half @canonicalize_inf_f16() {
423 ; CHECK-LABEL: @canonicalize_inf_f16(
424 ; CHECK-NEXT: ret half 0xH7C00
426 %ret = call half @llvm.canonicalize.f16(half 0xH7C00)
430 define half @canonicalize_neg_inf_f16() {
431 ; CHECK-LABEL: @canonicalize_neg_inf_f16(
432 ; CHECK-NEXT: ret half 0xHFC00
434 %ret = call half @llvm.canonicalize.f16(half 0xHFC00)
438 ; --------------------------------------------------------------------
440 ; --------------------------------------------------------------------
442 define fp128 @canonicalize_zero_fp128() {
443 ; CHECK-LABEL: @canonicalize_zero_fp128(
444 ; CHECK-NEXT: ret fp128 0xL00000000000000000000000000000000
446 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL00000000000000000000000000000000)
450 define fp128 @canonicalize_1.0_fp128() {
451 ; CHECK-LABEL: @canonicalize_1.0_fp128(
452 ; CHECK-NEXT: ret fp128 0xL00000000000000003FFF000000000000
454 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL00000000000000003FFF000000000000)
458 define fp128 @canonicalize_0x00000000000000000000000000000001_fp128() {
459 ; CHECK-LABEL: @canonicalize_0x00000000000000000000000000000001_fp128(
460 ; CHECK-NEXT: ret fp128 0xL00000000000000000000000000000001
462 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL00000000000000000000000000000001)
466 define fp128 @canonicalize_inf_fp128() {
467 ; CHECK-LABEL: @canonicalize_inf_fp128(
468 ; CHECK-NEXT: ret fp128 0xL00000000000000007FFF000000000000
470 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL00000000000000007FFF000000000000)
474 define fp128 @canonicalize_neg_inf_fp128() {
475 ; CHECK-LABEL: @canonicalize_neg_inf_fp128(
476 ; CHECK-NEXT: ret fp128 0xL0000000000000000FFFF000000000000
478 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL0000000000000000FFFF000000000000)
482 define fp128 @canonicalize_nan_fp128() {
483 ; CHECK-LABEL: @canonicalize_nan_fp128(
484 ; CHECK-NEXT: [[RET:%.*]] = call fp128 @llvm.canonicalize.f128(fp128 0xL00000000000000007FFF800000000000)
485 ; CHECK-NEXT: ret fp128 [[RET]]
487 %ret = call fp128 @llvm.canonicalize.fp128(fp128 0xL00000000000000007FFF800000000000)
491 ; --------------------------------------------------------------------
493 ; --------------------------------------------------------------------
495 define bfloat @canonicalize_zero_bf16() {
496 ; CHECK-LABEL: @canonicalize_zero_bf16(
497 ; CHECK-NEXT: ret bfloat 0xR0000
499 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0.0)
503 define bfloat @canonicalize_1.0_bf16() {
504 ; CHECK-LABEL: @canonicalize_1.0_bf16(
505 ; CHECK-NEXT: ret bfloat 0xR3F80
507 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 1.0)
511 define bfloat @canonicalize_0x0001_bf16() {
512 ; CHECK-LABEL: @canonicalize_0x0001_bf16(
513 ; CHECK-NEXT: ret bfloat 0xR0001
515 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0xR0001)
519 define bfloat @canonicalize_inf_bf16() {
520 ; CHECK-LABEL: @canonicalize_inf_bf16(
521 ; CHECK-NEXT: ret bfloat 0xR7F80
523 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0xR7F80)
527 define bfloat @canonicalize_neg_inf_bf16() {
528 ; CHECK-LABEL: @canonicalize_neg_inf_bf16(
529 ; CHECK-NEXT: ret bfloat 0xRFF80
531 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0xRFF80)
535 define bfloat @canonicalize_nan_bf16() {
536 ; CHECK-LABEL: @canonicalize_nan_bf16(
537 ; CHECK-NEXT: [[RET:%.*]] = call bfloat @llvm.canonicalize.bf16(bfloat 0xR7FC0)
538 ; CHECK-NEXT: ret bfloat [[RET]]
540 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0xR7FC0)
544 define bfloat @canonicalize_0xff_bf16() {
545 ; CHECK-LABEL: @canonicalize_0xff_bf16(
546 ; CHECK-NEXT: ret bfloat 0xR00FF
548 %ret = call bfloat @llvm.canonicalize.bf16(bfloat 0xR00FF)
552 ; --------------------------------------------------------------------
554 ; --------------------------------------------------------------------
556 define x86_fp80 @canonicalize_poison_f80() {
557 ; CHECK-LABEL: @canonicalize_poison_f80(
558 ; CHECK-NEXT: ret x86_fp80 poison
560 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 poison)
564 define x86_fp80 @canonicalize_undef_f80() {
565 ; CHECK-LABEL: @canonicalize_undef_f80(
566 ; CHECK-NEXT: ret x86_fp80 0xK00000000000000000000
568 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 undef)
572 define x86_fp80 @canonicalize_zero_f80() {
573 ; CHECK-LABEL: @canonicalize_zero_f80(
574 ; CHECK-NEXT: ret x86_fp80 0xK00000000000000000000
576 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK00000000000000000000)
580 define x86_fp80 @canonicalize_negzero_f80() {
581 ; CHECK-LABEL: @canonicalize_negzero_f80(
582 ; CHECK-NEXT: ret x86_fp80 0xK80000000000000000000
584 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK80000000000000000000)
588 define x86_fp80 @canonicalize_inf_f80() {
589 ; CHECK-LABEL: @canonicalize_inf_f80(
590 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK7FFF8000000000000000)
591 ; CHECK-NEXT: ret x86_fp80 [[RET]]
593 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK7FFF8000000000000000)
597 define x86_fp80 @canonicalize_ninf_f80() {
598 ; CHECK-LABEL: @canonicalize_ninf_f80(
599 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFF8000000000000000)
600 ; CHECK-NEXT: ret x86_fp80 [[RET]]
602 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFF8000000000000000)
606 define x86_fp80 @canonicalize_qnan_f80() {
607 ; CHECK-LABEL: @canonicalize_qnan_f80(
608 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFFC000000000000000)
609 ; CHECK-NEXT: ret x86_fp80 [[RET]]
611 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFFC000000000000000)
615 define x86_fp80 @canonicalize_snan_f80() {
616 ; CHECK-LABEL: @canonicalize_snan_f80(
617 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFFE000000000000000)
618 ; CHECK-NEXT: ret x86_fp80 [[RET]]
620 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKFFFFE000000000000000)
624 define x86_fp80 @canonicalize_1.0_f80() {
625 ; CHECK-LABEL: @canonicalize_1.0_f80(
626 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK3FFF8000000000000000)
627 ; CHECK-NEXT: ret x86_fp80 [[RET]]
629 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK3FFF8000000000000000)
633 define x86_fp80 @canonicalize_neg1.0_f80() {
634 ; CHECK-LABEL: @canonicalize_neg1.0_f80(
635 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKBFFF8000000000000000)
636 ; CHECK-NEXT: ret x86_fp80 [[RET]]
638 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xKBFFF8000000000000000)
642 define x86_fp80 @canonicalize_0xK00000000000000000001_f80() {
643 ; CHECK-LABEL: @canonicalize_0xK00000000000000000001_f80(
644 ; CHECK-NEXT: [[RET:%.*]] = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK00000000000000000001)
645 ; CHECK-NEXT: ret x86_fp80 [[RET]]
647 %ret = call x86_fp80 @llvm.canonicalize.f80(x86_fp80 0xK00000000000000000001)
651 ; --------------------------------------------------------------------
653 ; --------------------------------------------------------------------
655 define ppc_fp128 @canonicalize_poison_ppcf128() {
656 ; CHECK-LABEL: @canonicalize_poison_ppcf128(
657 ; CHECK-NEXT: ret ppc_fp128 poison
659 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 poison)
663 define ppc_fp128 @canonicalize_undef_ppcf128() {
664 ; CHECK-LABEL: @canonicalize_undef_ppcf128(
665 ; CHECK-NEXT: ret ppc_fp128 0xM00000000000000000000000000000000
667 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 undef)
671 define ppc_fp128 @canonicalize_zero_ppcf128() {
672 ; CHECK-LABEL: @canonicalize_zero_ppcf128(
673 ; CHECK-NEXT: ret ppc_fp128 0xM00000000000000000000000000000000
675 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM00000000000000000000000000000000)
679 define ppc_fp128 @canonicalize_negzero_ppcf128() {
680 ; CHECK-LABEL: @canonicalize_negzero_ppcf128(
681 ; CHECK-NEXT: ret ppc_fp128 0xM80000000000000000000000000000000
683 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM80000000000000000000000000000000)
687 define ppc_fp128 @canonicalize_noncanonical_zero_0_ppcf128() {
688 ; CHECK-LABEL: @canonicalize_noncanonical_zero_0_ppcf128(
689 ; CHECK-NEXT: ret ppc_fp128 0xM00000000000000000000000000000000
691 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM0000000000000000ffffffffffffffff)
695 define ppc_fp128 @canonicalize_noncanonical_zero_1_ppcf128() {
696 ; CHECK-LABEL: @canonicalize_noncanonical_zero_1_ppcf128(
697 ; CHECK-NEXT: ret ppc_fp128 0xM00000000000000000000000000000000
699 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM00000000000000000000000000000001)
703 define ppc_fp128 @canonicalize_noncanonical_negzero_0_ppcf128() {
704 ; CHECK-LABEL: @canonicalize_noncanonical_negzero_0_ppcf128(
705 ; CHECK-NEXT: ret ppc_fp128 0xM80000000000000000000000000000000
707 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM8000000000000000ffffffffffffffff)
711 define ppc_fp128 @canonicalize_inf_ppcf128() {
712 ; CHECK-LABEL: @canonicalize_inf_ppcf128(
713 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM7FF00000000000000000000000000000)
714 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
716 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM7FF00000000000000000000000000000)
720 define ppc_fp128 @canonicalize_neginf_ppcf128() {
721 ; CHECK-LABEL: @canonicalize_neginf_ppcf128(
722 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFF00000000000000000000000000000)
723 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
725 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFF00000000000000000000000000000)
729 define ppc_fp128 @canonicalize_qnan_ppcf128() {
730 ; CHECK-LABEL: @canonicalize_qnan_ppcf128(
731 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFF80000000000000000000000000000)
732 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
734 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFF80000000000000000000000000000)
738 define ppc_fp128 @canonicalize_snan_ppcf128() {
739 ; CHECK-LABEL: @canonicalize_snan_ppcf128(
740 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFFC0000000000000000000000000000)
741 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
743 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMFFFC0000000000000000000000000000)
747 define ppc_fp128 @canonicalize_1.0_ppcf128() {
748 ; CHECK-LABEL: @canonicalize_1.0_ppcf128(
749 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM3FF00000000000000000000000000000)
750 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
752 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xM3FF00000000000000000000000000000)
756 define ppc_fp128 @canonicalize_neg1.0_ppcf128() {
757 ; CHECK-LABEL: @canonicalize_neg1.0_ppcf128(
758 ; CHECK-NEXT: [[RET:%.*]] = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMBFF00000000000000000000000000000)
759 ; CHECK-NEXT: ret ppc_fp128 [[RET]]
761 %ret = call ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128 0xMBFF00000000000000000000000000000)
765 ; --------------------------------------------------------------------
766 ; Test folds of using canonicalize + is.fpclass to inspect the denormal mode.
767 ; --------------------------------------------------------------------
769 define i1 @is_poszero_daz_enabled_check_dynamic() "denormal-fp-math"="ieee,dynamic" {
770 ; CHECK-LABEL: @is_poszero_daz_enabled_check_dynamic(
771 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0x36A0000000000000)
772 ; CHECK-NEXT: [[IS_POS_ZERO:%.*]] = call i1 @llvm.is.fpclass.f32(float [[CANONICAL]], i32 64)
773 ; CHECK-NEXT: ret i1 [[IS_POS_ZERO]]
775 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
776 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
780 define i1 @is_preserve_sign_daz_enabled_check_dynamic() "denormal-fp-math"="ieee,dynamic" {
781 ; CHECK-LABEL: @is_preserve_sign_daz_enabled_check_dynamic(
782 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0xB6A0000000000000)
783 ; CHECK-NEXT: [[IS_NEG_ZERO:%.*]] = call i1 @llvm.is.fpclass.f32(float [[CANONICAL]], i32 32)
784 ; CHECK-NEXT: ret i1 [[IS_NEG_ZERO]]
786 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
787 %is.neg.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 32)
791 define i1 @is_positive_zero_daz_enabled_check_dynamic() "denormal-fp-math"="ieee,dynamic" {
792 ; CHECK-LABEL: @is_positive_zero_daz_enabled_check_dynamic(
793 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0xB6A0000000000000)
794 ; CHECK-NEXT: [[IS_POS_ZERO:%.*]] = call i1 @llvm.is.fpclass.f32(float [[CANONICAL]], i32 64)
795 ; CHECK-NEXT: ret i1 [[IS_POS_ZERO]]
797 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
798 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
802 define i1 @is_any_daz_enabled_check_dynamic() "denormal-fp-math"="ieee,dynamic" {
803 ; CHECK-LABEL: @is_any_daz_enabled_check_dynamic(
804 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0xB6A0000000000000)
805 ; CHECK-NEXT: [[IS_ANY_ZERO:%.*]] = call i1 @llvm.is.fpclass.f32(float [[CANONICAL]], i32 96)
806 ; CHECK-NEXT: ret i1 [[IS_ANY_ZERO]]
808 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
809 %is.any.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 96)
813 define i1 @is_not_daz_enabled_check_dynamic() "denormal-fp-math"="ieee,dynamic" {
814 ; CHECK-LABEL: @is_not_daz_enabled_check_dynamic(
815 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0x36A0000000000000)
816 ; CHECK-NEXT: [[IS_NOT_POS_ZERO:%.*]] = call i1 @llvm.is.fpclass.f32(float [[CANONICAL]], i32 959)
817 ; CHECK-NEXT: ret i1 [[IS_NOT_POS_ZERO]]
819 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
820 %is.not.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 959)
821 ret i1 %is.not.pos.zero
824 define i1 @is_poszero_daz_enabled_check_ieee() "denormal-fp-math"="ieee,ieee" {
825 ; CHECK-LABEL: @is_poszero_daz_enabled_check_ieee(
826 ; CHECK-NEXT: ret i1 false
828 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
829 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
833 define i1 @is_preserve_sign_daz_enabled_check_ieee() "denormal-fp-math"="ieee,ieee" {
834 ; CHECK-LABEL: @is_preserve_sign_daz_enabled_check_ieee(
835 ; CHECK-NEXT: ret i1 false
837 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
838 %is.neg.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 32)
842 define i1 @is_positive_zero_daz_enabled_check_ieee() "denormal-fp-math"="ieee,ieee" {
843 ; CHECK-LABEL: @is_positive_zero_daz_enabled_check_ieee(
844 ; CHECK-NEXT: ret i1 false
846 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
847 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
851 define i1 @is_any_daz_enabled_check_ieee() "denormal-fp-math"="ieee,ieee" {
852 ; CHECK-LABEL: @is_any_daz_enabled_check_ieee(
853 ; CHECK-NEXT: ret i1 false
855 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
856 %is.any.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 96)
860 define i1 @is_not_daz_enabled_check_ieee() "denormal-fp-math"="ieee,ieee" {
861 ; CHECK-LABEL: @is_not_daz_enabled_check_ieee(
862 ; CHECK-NEXT: ret i1 true
864 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
865 %is.not.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 959)
866 ret i1 %is.not.pos.zero
869 define i1 @is_poszero_daz_enabled_check_preserve_sign() "denormal-fp-math"="ieee,preserve-sign" {
870 ; CHECK-LABEL: @is_poszero_daz_enabled_check_preserve_sign(
871 ; CHECK-NEXT: ret i1 true
873 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
874 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
878 define i1 @is_preserve_sign_daz_enabled_check_preserve_sign() "denormal-fp-math"="ieee,preserve-sign" {
879 ; CHECK-LABEL: @is_preserve_sign_daz_enabled_check_preserve_sign(
880 ; CHECK-NEXT: ret i1 true
882 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
883 %is.neg.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 32)
887 define i1 @is_positive_zero_daz_enabled_check_preserve_sign() "denormal-fp-math"="ieee,preserve-sign" {
888 ; CHECK-LABEL: @is_positive_zero_daz_enabled_check_preserve_sign(
889 ; CHECK-NEXT: ret i1 false
891 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
892 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
896 define i1 @is_any_daz_enabled_check_preserve_sign() "denormal-fp-math"="ieee,preserve-sign" {
897 ; CHECK-LABEL: @is_any_daz_enabled_check_preserve_sign(
898 ; CHECK-NEXT: ret i1 true
900 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
901 %is.any.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 96)
905 define i1 @is_not_daz_enabled_check_preserve_sign() "denormal-fp-math"="ieee,preserve-sign" {
906 ; CHECK-LABEL: @is_not_daz_enabled_check_preserve_sign(
907 ; CHECK-NEXT: ret i1 false
909 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
910 %is.not.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 959)
911 ret i1 %is.not.pos.zero
914 define i1 @is_poszero_daz_enabled_check_positive_zero() "denormal-fp-math"="ieee,positive-zero" {
915 ; CHECK-LABEL: @is_poszero_daz_enabled_check_positive_zero(
916 ; CHECK-NEXT: ret i1 true
918 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
919 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
923 define i1 @is_preserve_sign_daz_enabled_check_positive_zero() "denormal-fp-math"="ieee,positive-zero" {
924 ; CHECK-LABEL: @is_preserve_sign_daz_enabled_check_positive_zero(
925 ; CHECK-NEXT: ret i1 false
927 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
928 %is.neg.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 32)
932 define i1 @is_positive_zero_daz_enabled_check_positive_zero() "denormal-fp-math"="ieee,positive-zero" {
933 ; CHECK-LABEL: @is_positive_zero_daz_enabled_check_positive_zero(
934 ; CHECK-NEXT: ret i1 true
936 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
937 %is.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 64)
941 define i1 @is_any_daz_enabled_check_positive_zero() "denormal-fp-math"="ieee,positive-zero" {
942 ; CHECK-LABEL: @is_any_daz_enabled_check_positive_zero(
943 ; CHECK-NEXT: ret i1 true
945 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 -2147483647 to float))
946 %is.any.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 96)
950 define i1 @is_not_daz_enabled_check_positive_zero() "denormal-fp-math"="ieee,positive-zero" {
951 ; CHECK-LABEL: @is_not_daz_enabled_check_positive_zero(
952 ; CHECK-NEXT: ret i1 false
954 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
955 %is.not.pos.zero = call i1 @llvm.is.fpclass.f32(float %canonical, i32 959)
956 ret i1 %is.not.pos.zero
959 define i1 @is_poszero_daz_enabled_check_dynamic_bitcast() "denormal-fp-math"="ieee,dynamic" {
960 ; CHECK-LABEL: @is_poszero_daz_enabled_check_dynamic_bitcast(
961 ; CHECK-NEXT: [[CANONICAL:%.*]] = call float @llvm.canonicalize.f32(float 0x36A0000000000000)
962 ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast float [[CANONICAL]] to i32
963 ; CHECK-NEXT: [[IS_POS_ZERO:%.*]] = icmp eq i32 [[BITCAST]], 0
964 ; CHECK-NEXT: ret i1 [[IS_POS_ZERO]]
966 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
967 %bitcast = bitcast float %canonical to i32
968 %is.pos.zero = icmp eq i32 %bitcast, 0
972 define i1 @is_poszero_daz_enabled_check_preserve_sign_bitcast() "denormal-fp-math"="ieee,preserve-sign" {
973 ; CHECK-LABEL: @is_poszero_daz_enabled_check_preserve_sign_bitcast(
974 ; CHECK-NEXT: ret i1 true
976 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
977 %bitcast = bitcast float %canonical to i32
978 %is.pos.zero = icmp eq i32 %bitcast, 0
982 define i1 @is_poszero_daz_enabled_check_positive_zero_bitcast() "denormal-fp-math"="ieee,positive-zero" {
983 ; CHECK-LABEL: @is_poszero_daz_enabled_check_positive_zero_bitcast(
984 ; CHECK-NEXT: ret i1 true
986 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
987 %bitcast = bitcast float %canonical to i32
988 %is.pos.zero = icmp eq i32 %bitcast, 0
992 define i1 @is_poszero_daz_enabled_check_ieee_bitcast() "denormal-fp-math"="ieee,ieee" {
993 ; CHECK-LABEL: @is_poszero_daz_enabled_check_ieee_bitcast(
994 ; CHECK-NEXT: ret i1 false
996 %canonical = call float @llvm.canonicalize.f32(float bitcast (i32 1 to float))
997 %bitcast = bitcast float %canonical to i32
998 %is.pos.zero = icmp eq i32 %bitcast, 0
1002 declare bfloat @llvm.canonicalize.bf16(bfloat)
1003 declare half @llvm.canonicalize.f16(half)
1004 declare float @llvm.canonicalize.f32(float)
1005 declare <2 x float> @llvm.canonicalize.v2f32(<2 x float>)
1006 declare double @llvm.canonicalize.f64(double)
1007 declare fp128 @llvm.canonicalize.fp128(fp128)
1008 declare x86_fp80 @llvm.canonicalize.f80(x86_fp80)
1009 declare ppc_fp128 @llvm.canonicalize.ppcf128(ppc_fp128)
1010 declare i1 @llvm.is.fpclass.f32(float, i32 immarg)