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(
101 %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
104 declare double @llvm.pow.f64(double, double) nounwind readonly
106 define double @test_acos() nounwind uwtable ssp {
108 ; CHECK-LABEL: @test_acos(
110 %0 = call double @acos(double 3.000000e+00)
114 define double @test_asin() nounwind uwtable ssp {
116 ; CHECK-LABEL: @test_asin(
118 %0 = call double @asin(double 3.000000e+00)
122 define double @test_atan() nounwind uwtable ssp {
124 ; CHECK-LABEL: @test_atan(
126 %0 = call double @atan(double 3.000000e+00)
130 define double @test_atan2() nounwind uwtable ssp {
132 ; CHECK-LABEL: @test_atan2(
134 %0 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
138 define double @test_ceil() nounwind uwtable ssp {
140 ; CHECK-LABEL: @test_ceil(
142 %0 = call double @ceil(double 3.000000e+00)
146 define double @test_cos() nounwind uwtable ssp {
148 ; CHECK-LABEL: @test_cos(
150 %0 = call double @cos(double 3.000000e+00)
154 define double @test_cosh() nounwind uwtable ssp {
156 ; CHECK-LABEL: @test_cosh(
158 %0 = call double @cosh(double 3.000000e+00)
162 define double @test_exp() nounwind uwtable ssp {
164 ; CHECK-LABEL: @test_exp(
166 %0 = call double @exp(double 3.000000e+00)
170 define double @test_exp2() nounwind uwtable ssp {
172 ; CHECK-LABEL: @test_exp2(
174 %0 = call double @exp2(double 3.000000e+00)
178 define double @test_fabs() nounwind uwtable ssp {
180 ; CHECK-LABEL: @test_fabs(
182 %0 = call double @fabs(double 3.000000e+00)
186 define double @test_floor() nounwind uwtable ssp {
188 ; CHECK-LABEL: @test_floor(
190 %0 = call double @floor(double 3.000000e+00)
194 define double @test_fmod() nounwind uwtable ssp {
196 ; CHECK-LABEL: @test_fmod(
198 %0 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
202 define double @test_log() nounwind uwtable ssp {
204 ; CHECK-LABEL: @test_log(
206 %0 = call double @log(double 3.000000e+00)
210 define double @test_log10() nounwind uwtable ssp {
212 ; CHECK-LABEL: @test_log10(
214 %0 = call double @log10(double 3.000000e+00)
218 define double @test_pow() nounwind uwtable ssp {
220 ; CHECK-LABEL: @test_pow(
222 %0 = call double @pow(double 3.000000e+00, double 4.000000e+00)
226 define double @test_sin() nounwind uwtable ssp {
228 ; CHECK-LABEL: @test_sin(
230 %0 = call double @sin(double 3.000000e+00)
234 define double @test_sinh() nounwind uwtable ssp {
236 ; CHECK-LABEL: @test_sinh(
238 %0 = call double @sinh(double 3.000000e+00)
242 define double @test_sqrt() nounwind uwtable ssp {
244 ; CHECK-LABEL: @test_sqrt(
246 %0 = call double @sqrt(double 3.000000e+00)
250 define double @test_tan() nounwind uwtable ssp {
252 ; CHECK-LABEL: @test_tan(
254 %0 = call double @tan(double 3.000000e+00)
258 define double @test_tanh() nounwind uwtable ssp {
260 ; CHECK-LABEL: @test_tanh(
262 %0 = call double @tanh(double 3.000000e+00)
266 define float @test_acosf() nounwind uwtable ssp {
268 ; CHECK-LABEL: @test_acosf(
270 %0 = call float @acosf(float 3.000000e+00)
274 define float @test_asinf() nounwind uwtable ssp {
276 ; CHECK-LABEL: @test_asinf(
278 %0 = call float @asinf(float 3.000000e+00)
282 define float @test_atanf() nounwind uwtable ssp {
284 ; CHECK-LABEL: @test_atanf(
286 %0 = call float @atanf(float 3.000000e+00)
290 define float @test_atan2f() nounwind uwtable ssp {
292 ; CHECK-LABEL: @test_atan2f(
294 %0 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
298 define float @test_ceilf() nounwind uwtable ssp {
300 ; CHECK-LABEL: @test_ceilf(
302 %0 = call float @ceilf(float 3.000000e+00)
306 define float @test_cosf() nounwind uwtable ssp {
308 ; CHECK-LABEL: @test_cosf(
310 %0 = call float @cosf(float 3.000000e+00)
314 define float @test_coshf() nounwind uwtable ssp {
316 ; CHECK-LABEL: @test_coshf(
318 %0 = call float @coshf(float 3.000000e+00)
322 define float @test_expf() nounwind uwtable ssp {
324 ; CHECK-LABEL: @test_expf(
326 %0 = call float @expf(float 3.000000e+00)
330 define float @test_exp2f() nounwind uwtable ssp {
332 ; CHECK-LABEL: @test_exp2f(
334 %0 = call float @exp2f(float 3.000000e+00)
338 define float @test_fabsf() nounwind uwtable ssp {
340 ; CHECK-LABEL: @test_fabsf(
342 %0 = call float @fabsf(float 3.000000e+00)
346 define float @test_floorf() nounwind uwtable ssp {
348 ; CHECK-LABEL: @test_floorf(
350 %0 = call float @floorf(float 3.000000e+00)
354 define float @test_fmodf() nounwind uwtable ssp {
356 ; CHECK-LABEL: @test_fmodf(
358 %0 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
362 define float @test_logf() nounwind uwtable ssp {
364 ; CHECK-LABEL: @test_logf(
366 %0 = call float @logf(float 3.000000e+00)
370 define float @test_log10f() nounwind uwtable ssp {
372 ; CHECK-LABEL: @test_log10f(
374 %0 = call float @log10f(float 3.000000e+00)
378 define float @test_powf() nounwind uwtable ssp {
380 ; CHECK-LABEL: @test_powf(
382 %0 = call float @powf(float 3.000000e+00, float 4.000000e+00)
386 define float @test_sinf() nounwind uwtable ssp {
388 ; CHECK-LABEL: @test_sinf(
390 %0 = call float @sinf(float 3.000000e+00)
394 define float @test_sinhf() nounwind uwtable ssp {
396 ; CHECK-LABEL: @test_sinhf(
398 %0 = call float @sinhf(float 3.000000e+00)
402 define float @test_sqrtf() nounwind uwtable ssp {
404 ; CHECK-LABEL: @test_sqrtf(
406 %0 = call float @sqrtf(float 3.000000e+00)
410 define float @test_tanf() nounwind uwtable ssp {
412 ; CHECK-LABEL: @test_tanf(
414 %0 = call float @tanf(float 3.000000e+00)
418 define float @test_tanhf() nounwind uwtable ssp {
420 ; CHECK-LABEL: @test_tanhf(
422 %0 = call float @tanhf(float 3.000000e+00)
426 ; Shouldn't fold because of -fno-builtin
427 define double @acos_() nounwind uwtable ssp {
428 ; FNOBUILTIN-LABEL: @acos_(
429 ; FNOBUILTIN: %1 = call double @acos(double 3.000000e+00)
430 %1 = call double @acos(double 3.000000e+00)
434 ; Shouldn't fold because of -fno-builtin
435 define double @asin_() nounwind uwtable ssp {
436 ; FNOBUILTIN-LABEL: @asin_(
437 ; FNOBUILTIN: %1 = call double @asin(double 3.000000e+00)
438 %1 = call double @asin(double 3.000000e+00)
442 ; Shouldn't fold because of -fno-builtin
443 define double @atan_() nounwind uwtable ssp {
444 ; FNOBUILTIN-LABEL: @atan_(
445 ; FNOBUILTIN: %1 = call double @atan(double 3.000000e+00)
446 %1 = call double @atan(double 3.000000e+00)
450 ; Shouldn't fold because of -fno-builtin
451 define double @atan2_() nounwind uwtable ssp {
452 ; FNOBUILTIN-LABEL: @atan2_(
453 ; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
454 %1 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
458 ; Shouldn't fold because of -fno-builtin
459 define double @ceil_() nounwind uwtable ssp {
460 ; FNOBUILTIN-LABEL: @ceil_(
461 ; FNOBUILTIN: %1 = call double @ceil(double 3.000000e+00)
462 %1 = call double @ceil(double 3.000000e+00)
466 ; Shouldn't fold because of -fno-builtin
467 define double @cos_() nounwind uwtable ssp {
468 ; FNOBUILTIN-LABEL: @cos_(
469 ; FNOBUILTIN: %1 = call double @cos(double 3.000000e+00)
470 %1 = call double @cos(double 3.000000e+00)
474 ; Shouldn't fold because of -fno-builtin
475 define double @cosh_() nounwind uwtable ssp {
476 ; FNOBUILTIN-LABEL: @cosh_(
477 ; FNOBUILTIN: %1 = call double @cosh(double 3.000000e+00)
478 %1 = call double @cosh(double 3.000000e+00)
482 ; Shouldn't fold because of -fno-builtin
483 define double @exp_() nounwind uwtable ssp {
484 ; FNOBUILTIN-LABEL: @exp_(
485 ; FNOBUILTIN: %1 = call double @exp(double 3.000000e+00)
486 %1 = call double @exp(double 3.000000e+00)
490 ; Shouldn't fold because of -fno-builtin
491 define double @exp2_() nounwind uwtable ssp {
492 ; FNOBUILTIN-LABEL: @exp2_(
493 ; FNOBUILTIN: %1 = call double @exp2(double 3.000000e+00)
494 %1 = call double @exp2(double 3.000000e+00)
498 ; Shouldn't fold because of -fno-builtin
499 define double @fabs_() nounwind uwtable ssp {
500 ; FNOBUILTIN-LABEL: @fabs_(
501 ; FNOBUILTIN: %1 = call double @fabs(double 3.000000e+00)
502 %1 = call double @fabs(double 3.000000e+00)
506 ; Shouldn't fold because of -fno-builtin
507 define double @floor_() nounwind uwtable ssp {
508 ; FNOBUILTIN-LABEL: @floor_(
509 ; FNOBUILTIN: %1 = call double @floor(double 3.000000e+00)
510 %1 = call double @floor(double 3.000000e+00)
514 ; Shouldn't fold because of -fno-builtin
515 define double @fmod_() nounwind uwtable ssp {
516 ; FNOBUILTIN-LABEL: @fmod_(
517 ; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
518 %1 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
522 ; Shouldn't fold because of -fno-builtin
523 define double @log_() nounwind uwtable ssp {
524 ; FNOBUILTIN-LABEL: @log_(
525 ; FNOBUILTIN: %1 = call double @log(double 3.000000e+00)
526 %1 = call double @log(double 3.000000e+00)
530 ; Shouldn't fold because of -fno-builtin
531 define double @log10_() nounwind uwtable ssp {
532 ; FNOBUILTIN-LABEL: @log10_(
533 ; FNOBUILTIN: %1 = call double @log10(double 3.000000e+00)
534 %1 = call double @log10(double 3.000000e+00)
538 ; Shouldn't fold because of -fno-builtin
539 define double @pow_() nounwind uwtable ssp {
540 ; FNOBUILTIN-LABEL: @pow_(
541 ; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 4.000000e+00)
542 %1 = call double @pow(double 3.000000e+00, double 4.000000e+00)
546 ; Shouldn't fold because of -fno-builtin
547 define double @sin_() nounwind uwtable ssp {
548 ; FNOBUILTIN-LABEL: @sin_(
549 ; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
550 %1 = call double @sin(double 3.000000e+00)
554 ; Shouldn't fold because of -fno-builtin
555 define double @sinh_() nounwind uwtable ssp {
556 ; FNOBUILTIN-LABEL: @sinh_(
557 ; FNOBUILTIN: %1 = call double @sinh(double 3.000000e+00)
558 %1 = call double @sinh(double 3.000000e+00)
562 ; Shouldn't fold because of -fno-builtin
563 define double @sqrt_() nounwind uwtable ssp {
564 ; FNOBUILTIN-LABEL: @sqrt_(
565 ; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
566 %1 = call double @sqrt(double 3.000000e+00)
570 ; Shouldn't fold because of -fno-builtin
571 define double @tan_() nounwind uwtable ssp {
572 ; FNOBUILTIN-LABEL: @tan_(
573 ; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
574 %1 = call double @tan(double 3.000000e+00)
578 ; Shouldn't fold because of -fno-builtin
579 define double @tanh_() nounwind uwtable ssp {
580 ; FNOBUILTIN-LABEL: @tanh_(
581 ; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
582 %1 = call double @tanh(double 3.000000e+00)
586 ; Shouldn't fold because of -fno-builtin
587 define float @acosf_() nounwind uwtable ssp {
588 ; FNOBUILTIN-LABEL: @acosf_(
589 ; FNOBUILTIN: %1 = call float @acosf(float 3.000000e+00)
590 %1 = call float @acosf(float 3.000000e+00)
594 ; Shouldn't fold because of -fno-builtin
595 define float @asinf_() nounwind uwtable ssp {
596 ; FNOBUILTIN-LABEL: @asinf_(
597 ; FNOBUILTIN: %1 = call float @asinf(float 3.000000e+00)
598 %1 = call float @asinf(float 3.000000e+00)
602 ; Shouldn't fold because of -fno-builtin
603 define float @atanf_() nounwind uwtable ssp {
604 ; FNOBUILTIN-LABEL: @atanf_(
605 ; FNOBUILTIN: %1 = call float @atanf(float 3.000000e+00)
606 %1 = call float @atanf(float 3.000000e+00)
610 ; Shouldn't fold because of -fno-builtin
611 define float @atan2f_() nounwind uwtable ssp {
612 ; FNOBUILTIN-LABEL: @atan2f_(
613 ; FNOBUILTIN: %1 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
614 %1 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
618 ; Shouldn't fold because of -fno-builtin
619 define float @ceilf_() nounwind uwtable ssp {
620 ; FNOBUILTIN-LABEL: @ceilf_(
621 ; FNOBUILTIN: %1 = call float @ceilf(float 3.000000e+00)
622 %1 = call float @ceilf(float 3.000000e+00)
626 ; Shouldn't fold because of -fno-builtin
627 define float @cosf_() nounwind uwtable ssp {
628 ; FNOBUILTIN-LABEL: @cosf_(
629 ; FNOBUILTIN: %1 = call float @cosf(float 3.000000e+00)
630 %1 = call float @cosf(float 3.000000e+00)
634 ; Shouldn't fold because of -fno-builtin
635 define float @coshf_() nounwind uwtable ssp {
636 ; FNOBUILTIN-LABEL: @coshf_(
637 ; FNOBUILTIN: %1 = call float @coshf(float 3.000000e+00)
638 %1 = call float @coshf(float 3.000000e+00)
642 ; Shouldn't fold because of -fno-builtin
643 define float @expf_() nounwind uwtable ssp {
644 ; FNOBUILTIN-LABEL: @expf_(
645 ; FNOBUILTIN: %1 = call float @expf(float 3.000000e+00)
646 %1 = call float @expf(float 3.000000e+00)
650 ; Shouldn't fold because of -fno-builtin
651 define float @exp2f_() nounwind uwtable ssp {
652 ; FNOBUILTIN-LABEL: @exp2f_(
653 ; FNOBUILTIN: %1 = call float @exp2f(float 3.000000e+00)
654 %1 = call float @exp2f(float 3.000000e+00)
658 ; Shouldn't fold because of -fno-builtin
659 define float @fabsf_() nounwind uwtable ssp {
660 ; FNOBUILTIN-LABEL: @fabsf_(
661 ; FNOBUILTIN: %1 = call float @fabsf(float 3.000000e+00)
662 %1 = call float @fabsf(float 3.000000e+00)
666 ; Shouldn't fold because of -fno-builtin
667 define float @floorf_() nounwind uwtable ssp {
668 ; FNOBUILTIN-LABEL: @floorf_(
669 ; FNOBUILTIN: %1 = call float @floorf(float 3.000000e+00)
670 %1 = call float @floorf(float 3.000000e+00)
674 ; Shouldn't fold because of -fno-builtin
675 define float @fmodf_() nounwind uwtable ssp {
676 ; FNOBUILTIN-LABEL: @fmodf_(
677 ; FNOBUILTIN: %1 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
678 %1 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
682 ; Shouldn't fold because of -fno-builtin
683 define float @logf_() nounwind uwtable ssp {
684 ; FNOBUILTIN-LABEL: @logf_(
685 ; FNOBUILTIN: %1 = call float @logf(float 3.000000e+00)
686 %1 = call float @logf(float 3.000000e+00)
690 ; Shouldn't fold because of -fno-builtin
691 define float @log10f_() nounwind uwtable ssp {
692 ; FNOBUILTIN-LABEL: @log10f_(
693 ; FNOBUILTIN: %1 = call float @log10f(float 3.000000e+00)
694 %1 = call float @log10f(float 3.000000e+00)
698 ; Shouldn't fold because of -fno-builtin
699 define float @powf_() nounwind uwtable ssp {
700 ; FNOBUILTIN-LABEL: @powf_(
701 ; FNOBUILTIN: %1 = call float @powf(float 3.000000e+00, float 4.000000e+00)
702 %1 = call float @powf(float 3.000000e+00, float 4.000000e+00)
706 ; Shouldn't fold because of -fno-builtin
707 define float @sinf_() nounwind uwtable ssp {
708 ; FNOBUILTIN-LABEL: @sinf_(
709 ; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
710 %1 = call float @sinf(float 3.000000e+00)
714 ; Shouldn't fold because of -fno-builtin
715 define float @sinhf_() nounwind uwtable ssp {
716 ; FNOBUILTIN-LABEL: @sinhf_(
717 ; FNOBUILTIN: %1 = call float @sinhf(float 3.000000e+00)
718 %1 = call float @sinhf(float 3.000000e+00)
722 ; Shouldn't fold because of -fno-builtin
723 define float @sqrtf_() nounwind uwtable ssp {
724 ; FNOBUILTIN-LABEL: @sqrtf_(
725 ; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
726 %1 = call float @sqrtf(float 3.000000e+00)
730 ; Shouldn't fold because of -fno-builtin
731 define float @tanf_() nounwind uwtable ssp {
732 ; FNOBUILTIN-LABEL: @tanf_(
733 ; FNOBUILTIN: %1 = call float @tanf(float 3.000000e+00)
734 %1 = call float @tanf(float 3.000000e+00)
738 ; Shouldn't fold because of -fno-builtin
739 define float @tanhf_() nounwind uwtable ssp {
740 ; FNOBUILTIN-LABEL: @tanhf_(
741 ; FNOBUILTIN: %1 = call float @tanhf(float 3.000000e+00)
742 %1 = call float @tanhf(float 3.000000e+00)