blob: 7a405a539c51f945b3708015489f0a1597c88ed7 [file] [log] [blame]
Chandler Carruthf7b00472011-01-11 01:07:20 +00001; RUN: opt < %s -constprop -S | FileCheck %s
Chad Rosieraebc3aa2011-12-01 22:14:50 +00002; RUN: opt < %s -constprop -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
Chris Lattnercc713a32004-04-13 19:28:09 +00003
Tanya Lattnerec9a35a2008-03-01 09:15:35 +00004declare double @cos(double)
Chris Lattnercc713a32004-04-13 19:28:09 +00005
Tanya Lattnerec9a35a2008-03-01 09:15:35 +00006declare double @sin(double)
7
8declare double @tan(double)
9
10declare double @sqrt(double)
Chris Lattner805fa972011-05-22 22:22:35 +000011declare double @exp2(double)
Tanya Lattnerec9a35a2008-03-01 09:15:35 +000012
Tanya Lattnerec9a35a2008-03-01 09:15:35 +000013define double @T() {
Chandler Carruthf7b00472011-01-11 01:07:20 +000014; CHECK: @T
15; CHECK-NOT: call
16; CHECK: ret
17 %A = call double @cos(double 0.000000e+00)
18 %B = call double @sin(double 0.000000e+00)
19 %a = fadd double %A, %B
20 %C = call double @tan(double 0.000000e+00)
21 %b = fadd double %a, %C
22 %D = call double @sqrt(double 4.000000e+00)
23 %c = fadd double %b, %D
Chris Lattner805fa972011-05-22 22:22:35 +000024
25 ; PR9315
26 %E = call double @exp2(double 4.0)
27 %d = fadd double %c, %E
28 ret double %d
Chris Lattnercc713a32004-04-13 19:28:09 +000029}
Chandler Carruth15ed90c2011-01-11 01:07:24 +000030
31define i1 @test_sse_cvt() nounwind readnone {
32; CHECK: @test_sse_cvt
33; CHECK-NOT: call
34; CHECK: ret i1 true
35entry:
36 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
37 %i1 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
38 %i2 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
39 %i3 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
40 %i4 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 1.75, double undef>) nounwind
41 %i5 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 1.75, double undef>) nounwind
42 %i6 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 1.75, double undef>) nounwind
43 %i7 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 1.75, double undef>) nounwind
44 %sum11 = add i32 %i0, %i1
45 %sum12 = add i32 %i4, %i5
46 %sum1 = add i32 %sum11, %sum12
47 %sum21 = add i64 %i2, %i3
48 %sum22 = add i64 %i6, %i7
49 %sum2 = add i64 %sum21, %sum22
50 %sum1.sext = sext i32 %sum1 to i64
51 %b = icmp eq i64 %sum1.sext, %sum2
52 ret i1 %b
53}
54
55declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone
56declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone
57declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone
58declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone
59declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
60declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone
61declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone
62declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone
Chad Rosieraebc3aa2011-12-01 22:14:50 +000063
Chad Rosier24fbf2b2011-12-03 00:00:03 +000064define double @test_intrinsic_pow() nounwind uwtable ssp {
65entry:
66; CHECK: @test_intrinsic_pow
67; CHECK-NOT: call
68 %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
69 ret double %0
70}
71declare double @llvm.pow.f64(double, double) nounwind readonly
72
Chad Rosieraebc3aa2011-12-01 22:14:50 +000073; Shouldn't fold because of -fno-builtin
74define double @sin_() nounwind uwtable ssp {
75; FNOBUILTIN: @sin_
76; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
77 %1 = call double @sin(double 3.000000e+00)
78 ret double %1
79}
80
81; Shouldn't fold because of -fno-builtin
82define double @sqrt_() nounwind uwtable ssp {
83; FNOBUILTIN: @sqrt_
84; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
85 %1 = call double @sqrt(double 3.000000e+00)
86 ret double %1
87}
88
89; Shouldn't fold because of -fno-builtin
90define float @sqrtf_() nounwind uwtable ssp {
91; FNOBUILTIN: @sqrtf_
92; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
93 %1 = call float @sqrtf(float 3.000000e+00)
94 ret float %1
95}
96declare float @sqrtf(float)
97
98; Shouldn't fold because of -fno-builtin
99define float @sinf_() nounwind uwtable ssp {
100; FNOBUILTIN: @sinf_
101; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
102 %1 = call float @sinf(float 3.000000e+00)
103 ret float %1
104}
105declare float @sinf(float)
106
107; Shouldn't fold because of -fno-builtin
108define double @tan_() nounwind uwtable ssp {
109; FNOBUILTIN: @tan_
110; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
111 %1 = call double @tan(double 3.000000e+00)
112 ret double %1
113}
114
115; Shouldn't fold because of -fno-builtin
116define double @tanh_() nounwind uwtable ssp {
117; FNOBUILTIN: @tanh_
118; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
119 %1 = call double @tanh(double 3.000000e+00)
120 ret double %1
121}
122declare double @tanh(double)
123
124; Shouldn't fold because of -fno-builtin
125define double @pow_() nounwind uwtable ssp {
126; FNOBUILTIN: @pow_
127; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
128 %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
129 ret double %1
130}
131declare double @pow(double, double)
132
133; Shouldn't fold because of -fno-builtin
134define double @fmod_() nounwind uwtable ssp {
135; FNOBUILTIN: @fmod_
136; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
137 %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
138 ret double %1
139}
140declare double @fmod(double, double)
141
142; Shouldn't fold because of -fno-builtin
143define double @atan2_() nounwind uwtable ssp {
144; FNOBUILTIN: @atan2_
145; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
146 %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
147 ret double %1
148}
149declare double @atan2(double, double)