1 ; RUN: opt < %s -constprop -S | FileCheck %s
2 ; RUN: opt < %s -constprop -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
4 declare double @acos(double)
5 declare double @asin(double)
6 declare double @atan(double)
7 declare double @atan2(double, double)
8 declare double @ceil(double)
9 declare double @cos(double)
10 declare double @cosh(double)
11 declare double @exp(double)
12 declare double @exp2(double)
13 declare double @fabs(double)
14 declare double @floor(double)
15 declare double @fmod(double, double)
16 declare double @log(double)
17 declare double @log10(double)
18 declare double @pow(double, double)
19 declare double @sin(double)
20 declare double @sinh(double)
21 declare double @sqrt(double)
22 declare double @tan(double)
23 declare double @tanh(double)
25 declare float @acosf(float)
26 declare float @asinf(float)
27 declare float @atanf(float)
28 declare float @atan2f(float, float)
29 declare float @ceilf(float)
30 declare float @cosf(float)
31 declare float @coshf(float)
32 declare float @expf(float)
33 declare float @exp2f(float)
34 declare float @fabsf(float)
35 declare float @floorf(float)
36 declare float @fmodf(float, float)
37 declare float @logf(float)
38 declare float @log10f(float)
39 declare float @powf(float, float)
40 declare float @sinf(float)
41 declare float @sinhf(float)
42 declare float @sqrtf(float)
43 declare float @tanf(float)
44 declare float @tanhf(float)
50 %A = call double @cos(double 0.000000e+00)
51 %B = call double @sin(double 0.000000e+00)
52 %a = fadd double %A, %B
53 %C = call double @tan(double 0.000000e+00)
54 %b = fadd double %a, %C
55 %D = call double @sqrt(double 4.000000e+00)
56 %c = fadd double %b, %D
59 %E = call double @exp2(double 4.0)
60 %d = fadd double %c, %E
64 define i1 @test_sse_cvt() nounwind readnone {
65 ; CHECK-LABEL: @test_sse_cvt(
69 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
70 %i1 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
71 %i2 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
72 %i3 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
73 %i4 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 1.75, double undef>) nounwind
74 %i5 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 1.75, double undef>) nounwind
75 %i6 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 1.75, double undef>) nounwind
76 %i7 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 1.75, double undef>) nounwind
77 %sum11 = add i32 %i0, %i1
78 %sum12 = add i32 %i4, %i5
79 %sum1 = add i32 %sum11, %sum12
80 %sum21 = add i64 %i2, %i3
81 %sum22 = add i64 %i6, %i7
82 %sum2 = add i64 %sum21, %sum22
83 %sum1.sext = sext i32 %sum1 to i64
84 %b = icmp eq i64 %sum1.sext, %sum2
88 declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone
89 declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone
90 declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone
91 declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone
92 declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
93 declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone
94 declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone
95 declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone
97 define double @test_intrinsic_pow() nounwind uwtable ssp {
99 ; CHECK-LABEL: @test_intrinsic_pow(
102 %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
105 declare double @llvm.pow.f64(double, double) nounwind readonly
107 define double @test_acos() nounwind uwtable ssp {
109 ; CHECK-LABEL: @test_acos(
112 %0 = call double @acos(double 1.000000e+00)
116 define double @test_asin() nounwind uwtable ssp {
118 ; CHECK-LABEL: @test_asin(
121 %0 = call double @asin(double 1.000000e+00)
125 define double @test_atan() nounwind uwtable ssp {
127 ; CHECK-LABEL: @test_atan(
130 %0 = call double @atan(double 3.000000e+00)
134 define double @test_atan2() nounwind uwtable ssp {
136 ; CHECK-LABEL: @test_atan2(
139 %0 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
143 define double @test_ceil() nounwind uwtable ssp {
145 ; CHECK-LABEL: @test_ceil(
148 %0 = call double @ceil(double 3.000000e+00)
152 define double @test_cos() nounwind uwtable ssp {
154 ; CHECK-LABEL: @test_cos(
157 %0 = call double @cos(double 3.000000e+00)
161 define double @test_cosh() nounwind uwtable ssp {
163 ; CHECK-LABEL: @test_cosh(
166 %0 = call double @cosh(double 3.000000e+00)
170 define double @test_exp() nounwind uwtable ssp {
172 ; CHECK-LABEL: @test_exp(
175 %0 = call double @exp(double 3.000000e+00)
179 define double @test_exp2() nounwind uwtable ssp {
181 ; CHECK-LABEL: @test_exp2(
184 %0 = call double @exp2(double 3.000000e+00)
188 define double @test_fabs() nounwind uwtable ssp {
190 ; CHECK-LABEL: @test_fabs(
193 %0 = call double @fabs(double 3.000000e+00)
197 define double @test_floor() nounwind uwtable ssp {
199 ; CHECK-LABEL: @test_floor(
202 %0 = call double @floor(double 3.000000e+00)
206 define double @test_fmod() nounwind uwtable ssp {
208 ; CHECK-LABEL: @test_fmod(
211 %0 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
215 define double @test_log() nounwind uwtable ssp {
217 ; CHECK-LABEL: @test_log(
220 %0 = call double @log(double 3.000000e+00)
224 define double @test_log10() nounwind uwtable ssp {
226 ; CHECK-LABEL: @test_log10(
229 %0 = call double @log10(double 3.000000e+00)
233 define double @test_pow() nounwind uwtable ssp {
235 ; CHECK-LABEL: @test_pow(
238 %0 = call double @pow(double 3.000000e+00, double 4.000000e+00)
242 define double @test_sin() nounwind uwtable ssp {
244 ; CHECK-LABEL: @test_sin(
247 %0 = call double @sin(double 3.000000e+00)
251 define double @test_sinh() nounwind uwtable ssp {
253 ; CHECK-LABEL: @test_sinh(
256 %0 = call double @sinh(double 3.000000e+00)
260 define double @test_sqrt() nounwind uwtable ssp {
262 ; CHECK-LABEL: @test_sqrt(
265 %0 = call double @sqrt(double 3.000000e+00)
269 define double @test_tan() nounwind uwtable ssp {
271 ; CHECK-LABEL: @test_tan(
274 %0 = call double @tan(double 3.000000e+00)
278 define double @test_tanh() nounwind uwtable ssp {
280 ; CHECK-LABEL: @test_tanh(
283 %0 = call double @tanh(double 3.000000e+00)
287 define float @test_acosf() nounwind uwtable ssp {
289 ; CHECK-LABEL: @test_acosf(
292 %0 = call float @acosf(float 1.000000e+00)
296 define float @test_asinf() nounwind uwtable ssp {
298 ; CHECK-LABEL: @test_asinf(
301 %0 = call float @asinf(float 1.000000e+00)
305 define float @test_atanf() nounwind uwtable ssp {
307 ; CHECK-LABEL: @test_atanf(
310 %0 = call float @atanf(float 3.000000e+00)
314 define float @test_atan2f() nounwind uwtable ssp {
316 ; CHECK-LABEL: @test_atan2f(
319 %0 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
323 define float @test_ceilf() nounwind uwtable ssp {
325 ; CHECK-LABEL: @test_ceilf(
328 %0 = call float @ceilf(float 3.000000e+00)
332 define float @test_cosf() nounwind uwtable ssp {
334 ; CHECK-LABEL: @test_cosf(
337 %0 = call float @cosf(float 3.000000e+00)
341 define float @test_coshf() nounwind uwtable ssp {
343 ; CHECK-LABEL: @test_coshf(
346 %0 = call float @coshf(float 3.000000e+00)
350 define float @test_expf() nounwind uwtable ssp {
352 ; CHECK-LABEL: @test_expf(
355 %0 = call float @expf(float 3.000000e+00)
359 define float @test_exp2f() nounwind uwtable ssp {
361 ; CHECK-LABEL: @test_exp2f(
364 %0 = call float @exp2f(float 3.000000e+00)
368 define float @test_fabsf() nounwind uwtable ssp {
370 ; CHECK-LABEL: @test_fabsf(
373 %0 = call float @fabsf(float 3.000000e+00)
377 define float @test_floorf() nounwind uwtable ssp {
379 ; CHECK-LABEL: @test_floorf(
382 %0 = call float @floorf(float 3.000000e+00)
386 define float @test_fmodf() nounwind uwtable ssp {
388 ; CHECK-LABEL: @test_fmodf(
391 %0 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
395 define float @test_logf() nounwind uwtable ssp {
397 ; CHECK-LABEL: @test_logf(
400 %0 = call float @logf(float 3.000000e+00)
404 define float @test_log10f() nounwind uwtable ssp {
406 ; CHECK-LABEL: @test_log10f(
409 %0 = call float @log10f(float 3.000000e+00)
413 define float @test_powf() nounwind uwtable ssp {
415 ; CHECK-LABEL: @test_powf(
418 %0 = call float @powf(float 3.000000e+00, float 4.000000e+00)
422 define float @test_sinf() nounwind uwtable ssp {
424 ; CHECK-LABEL: @test_sinf(
427 %0 = call float @sinf(float 3.000000e+00)
431 define float @test_sinhf() nounwind uwtable ssp {
433 ; CHECK-LABEL: @test_sinhf(
436 %0 = call float @sinhf(float 3.000000e+00)
440 define float @test_sqrtf() nounwind uwtable ssp {
442 ; CHECK-LABEL: @test_sqrtf(
445 %0 = call float @sqrtf(float 3.000000e+00)
449 define float @test_tanf() nounwind uwtable ssp {
451 ; CHECK-LABEL: @test_tanf(
454 %0 = call float @tanf(float 3.000000e+00)
458 define float @test_tanhf() nounwind uwtable ssp {
460 ; CHECK-LABEL: @test_tanhf(
463 %0 = call float @tanhf(float 3.000000e+00)
467 ; Shouldn't fold because of -fno-builtin
468 define double @acos_() nounwind uwtable ssp {
469 ; FNOBUILTIN-LABEL: @acos_(
470 ; FNOBUILTIN: %1 = call double @acos(double 3.000000e+00)
471 %1 = call double @acos(double 3.000000e+00)
475 ; Shouldn't fold because of -fno-builtin
476 define double @asin_() nounwind uwtable ssp {
477 ; FNOBUILTIN-LABEL: @asin_(
478 ; FNOBUILTIN: %1 = call double @asin(double 3.000000e+00)
479 %1 = call double @asin(double 3.000000e+00)
483 ; Shouldn't fold because of -fno-builtin
484 define double @atan_() nounwind uwtable ssp {
485 ; FNOBUILTIN-LABEL: @atan_(
486 ; FNOBUILTIN: %1 = call double @atan(double 3.000000e+00)
487 %1 = call double @atan(double 3.000000e+00)
491 ; Shouldn't fold because of -fno-builtin
492 define double @atan2_() nounwind uwtable ssp {
493 ; FNOBUILTIN-LABEL: @atan2_(
494 ; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
495 %1 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
499 ; Shouldn't fold because of -fno-builtin
500 define double @ceil_() nounwind uwtable ssp {
501 ; FNOBUILTIN-LABEL: @ceil_(
502 ; FNOBUILTIN: %1 = call double @ceil(double 3.000000e+00)
503 %1 = call double @ceil(double 3.000000e+00)
507 ; Shouldn't fold because of -fno-builtin
508 define double @cos_() nounwind uwtable ssp {
509 ; FNOBUILTIN-LABEL: @cos_(
510 ; FNOBUILTIN: %1 = call double @cos(double 3.000000e+00)
511 %1 = call double @cos(double 3.000000e+00)
515 ; Shouldn't fold because of -fno-builtin
516 define double @cosh_() nounwind uwtable ssp {
517 ; FNOBUILTIN-LABEL: @cosh_(
518 ; FNOBUILTIN: %1 = call double @cosh(double 3.000000e+00)
519 %1 = call double @cosh(double 3.000000e+00)
523 ; Shouldn't fold because of -fno-builtin
524 define double @exp_() nounwind uwtable ssp {
525 ; FNOBUILTIN-LABEL: @exp_(
526 ; FNOBUILTIN: %1 = call double @exp(double 3.000000e+00)
527 %1 = call double @exp(double 3.000000e+00)
531 ; Shouldn't fold because of -fno-builtin
532 define double @exp2_() nounwind uwtable ssp {
533 ; FNOBUILTIN-LABEL: @exp2_(
534 ; FNOBUILTIN: %1 = call double @exp2(double 3.000000e+00)
535 %1 = call double @exp2(double 3.000000e+00)
539 ; Shouldn't fold because of -fno-builtin
540 define double @fabs_() nounwind uwtable ssp {
541 ; FNOBUILTIN-LABEL: @fabs_(
542 ; FNOBUILTIN: %1 = call double @fabs(double 3.000000e+00)
543 %1 = call double @fabs(double 3.000000e+00)
547 ; Shouldn't fold because of -fno-builtin
548 define double @floor_() nounwind uwtable ssp {
549 ; FNOBUILTIN-LABEL: @floor_(
550 ; FNOBUILTIN: %1 = call double @floor(double 3.000000e+00)
551 %1 = call double @floor(double 3.000000e+00)
555 ; Shouldn't fold because of -fno-builtin
556 define double @fmod_() nounwind uwtable ssp {
557 ; FNOBUILTIN-LABEL: @fmod_(
558 ; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
559 %1 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
563 ; Shouldn't fold because of -fno-builtin
564 define double @log_() nounwind uwtable ssp {
565 ; FNOBUILTIN-LABEL: @log_(
566 ; FNOBUILTIN: %1 = call double @log(double 3.000000e+00)
567 %1 = call double @log(double 3.000000e+00)
571 ; Shouldn't fold because of -fno-builtin
572 define double @log10_() nounwind uwtable ssp {
573 ; FNOBUILTIN-LABEL: @log10_(
574 ; FNOBUILTIN: %1 = call double @log10(double 3.000000e+00)
575 %1 = call double @log10(double 3.000000e+00)
579 ; Shouldn't fold because of -fno-builtin
580 define double @pow_() nounwind uwtable ssp {
581 ; FNOBUILTIN-LABEL: @pow_(
582 ; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 4.000000e+00)
583 %1 = call double @pow(double 3.000000e+00, double 4.000000e+00)
587 ; Shouldn't fold because of -fno-builtin
588 define double @sin_() nounwind uwtable ssp {
589 ; FNOBUILTIN-LABEL: @sin_(
590 ; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
591 %1 = call double @sin(double 3.000000e+00)
595 ; Shouldn't fold because of -fno-builtin
596 define double @sinh_() nounwind uwtable ssp {
597 ; FNOBUILTIN-LABEL: @sinh_(
598 ; FNOBUILTIN: %1 = call double @sinh(double 3.000000e+00)
599 %1 = call double @sinh(double 3.000000e+00)
603 ; Shouldn't fold because of -fno-builtin
604 define double @sqrt_() nounwind uwtable ssp {
605 ; FNOBUILTIN-LABEL: @sqrt_(
606 ; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
607 %1 = call double @sqrt(double 3.000000e+00)
611 ; Shouldn't fold because of -fno-builtin
612 define double @tan_() nounwind uwtable ssp {
613 ; FNOBUILTIN-LABEL: @tan_(
614 ; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
615 %1 = call double @tan(double 3.000000e+00)
619 ; Shouldn't fold because of -fno-builtin
620 define double @tanh_() nounwind uwtable ssp {
621 ; FNOBUILTIN-LABEL: @tanh_(
622 ; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
623 %1 = call double @tanh(double 3.000000e+00)
627 ; Shouldn't fold because of -fno-builtin
628 define float @acosf_() nounwind uwtable ssp {
629 ; FNOBUILTIN-LABEL: @acosf_(
630 ; FNOBUILTIN: %1 = call float @acosf(float 3.000000e+00)
631 %1 = call float @acosf(float 3.000000e+00)
635 ; Shouldn't fold because of -fno-builtin
636 define float @asinf_() nounwind uwtable ssp {
637 ; FNOBUILTIN-LABEL: @asinf_(
638 ; FNOBUILTIN: %1 = call float @asinf(float 3.000000e+00)
639 %1 = call float @asinf(float 3.000000e+00)
643 ; Shouldn't fold because of -fno-builtin
644 define float @atanf_() nounwind uwtable ssp {
645 ; FNOBUILTIN-LABEL: @atanf_(
646 ; FNOBUILTIN: %1 = call float @atanf(float 3.000000e+00)
647 %1 = call float @atanf(float 3.000000e+00)
651 ; Shouldn't fold because of -fno-builtin
652 define float @atan2f_() nounwind uwtable ssp {
653 ; FNOBUILTIN-LABEL: @atan2f_(
654 ; FNOBUILTIN: %1 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
655 %1 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
659 ; Shouldn't fold because of -fno-builtin
660 define float @ceilf_() nounwind uwtable ssp {
661 ; FNOBUILTIN-LABEL: @ceilf_(
662 ; FNOBUILTIN: %1 = call float @ceilf(float 3.000000e+00)
663 %1 = call float @ceilf(float 3.000000e+00)
667 ; Shouldn't fold because of -fno-builtin
668 define float @cosf_() nounwind uwtable ssp {
669 ; FNOBUILTIN-LABEL: @cosf_(
670 ; FNOBUILTIN: %1 = call float @cosf(float 3.000000e+00)
671 %1 = call float @cosf(float 3.000000e+00)
675 ; Shouldn't fold because of -fno-builtin
676 define float @coshf_() nounwind uwtable ssp {
677 ; FNOBUILTIN-LABEL: @coshf_(
678 ; FNOBUILTIN: %1 = call float @coshf(float 3.000000e+00)
679 %1 = call float @coshf(float 3.000000e+00)
683 ; Shouldn't fold because of -fno-builtin
684 define float @expf_() nounwind uwtable ssp {
685 ; FNOBUILTIN-LABEL: @expf_(
686 ; FNOBUILTIN: %1 = call float @expf(float 3.000000e+00)
687 %1 = call float @expf(float 3.000000e+00)
691 ; Shouldn't fold because of -fno-builtin
692 define float @exp2f_() nounwind uwtable ssp {
693 ; FNOBUILTIN-LABEL: @exp2f_(
694 ; FNOBUILTIN: %1 = call float @exp2f(float 3.000000e+00)
695 %1 = call float @exp2f(float 3.000000e+00)
699 ; Shouldn't fold because of -fno-builtin
700 define float @fabsf_() nounwind uwtable ssp {
701 ; FNOBUILTIN-LABEL: @fabsf_(
702 ; FNOBUILTIN: %1 = call float @fabsf(float 3.000000e+00)
703 %1 = call float @fabsf(float 3.000000e+00)
707 ; Shouldn't fold because of -fno-builtin
708 define float @floorf_() nounwind uwtable ssp {
709 ; FNOBUILTIN-LABEL: @floorf_(
710 ; FNOBUILTIN: %1 = call float @floorf(float 3.000000e+00)
711 %1 = call float @floorf(float 3.000000e+00)
715 ; Shouldn't fold because of -fno-builtin
716 define float @fmodf_() nounwind uwtable ssp {
717 ; FNOBUILTIN-LABEL: @fmodf_(
718 ; FNOBUILTIN: %1 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
719 %1 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
723 ; Shouldn't fold because of -fno-builtin
724 define float @logf_() nounwind uwtable ssp {
725 ; FNOBUILTIN-LABEL: @logf_(
726 ; FNOBUILTIN: %1 = call float @logf(float 3.000000e+00)
727 %1 = call float @logf(float 3.000000e+00)
731 ; Shouldn't fold because of -fno-builtin
732 define float @log10f_() nounwind uwtable ssp {
733 ; FNOBUILTIN-LABEL: @log10f_(
734 ; FNOBUILTIN: %1 = call float @log10f(float 3.000000e+00)
735 %1 = call float @log10f(float 3.000000e+00)
739 ; Shouldn't fold because of -fno-builtin
740 define float @powf_() nounwind uwtable ssp {
741 ; FNOBUILTIN-LABEL: @powf_(
742 ; FNOBUILTIN: %1 = call float @powf(float 3.000000e+00, float 4.000000e+00)
743 %1 = call float @powf(float 3.000000e+00, float 4.000000e+00)
747 ; Shouldn't fold because of -fno-builtin
748 define float @sinf_() nounwind uwtable ssp {
749 ; FNOBUILTIN-LABEL: @sinf_(
750 ; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
751 %1 = call float @sinf(float 3.000000e+00)
755 ; Shouldn't fold because of -fno-builtin
756 define float @sinhf_() nounwind uwtable ssp {
757 ; FNOBUILTIN-LABEL: @sinhf_(
758 ; FNOBUILTIN: %1 = call float @sinhf(float 3.000000e+00)
759 %1 = call float @sinhf(float 3.000000e+00)
763 ; Shouldn't fold because of -fno-builtin
764 define float @sqrtf_() nounwind uwtable ssp {
765 ; FNOBUILTIN-LABEL: @sqrtf_(
766 ; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
767 %1 = call float @sqrtf(float 3.000000e+00)
771 ; Shouldn't fold because of -fno-builtin
772 define float @tanf_() nounwind uwtable ssp {
773 ; FNOBUILTIN-LABEL: @tanf_(
774 ; FNOBUILTIN: %1 = call float @tanf(float 3.000000e+00)
775 %1 = call float @tanf(float 3.000000e+00)
779 ; Shouldn't fold because of -fno-builtin
780 define float @tanhf_() nounwind uwtable ssp {
781 ; FNOBUILTIN-LABEL: @tanhf_(
782 ; FNOBUILTIN: %1 = call float @tanhf(float 3.000000e+00)
783 %1 = call float @tanhf(float 3.000000e+00)