blob: b3ea122406c3ba0eac81f90a1571b70163f54425 [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
64; Shouldn't fold because of -fno-builtin
65define double @sin_() nounwind uwtable ssp {
66; FNOBUILTIN: @sin_
67; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
68 %1 = call double @sin(double 3.000000e+00)
69 ret double %1
70}
71
72; Shouldn't fold because of -fno-builtin
73define double @sqrt_() nounwind uwtable ssp {
74; FNOBUILTIN: @sqrt_
75; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
76 %1 = call double @sqrt(double 3.000000e+00)
77 ret double %1
78}
79
80; Shouldn't fold because of -fno-builtin
81define float @sqrtf_() nounwind uwtable ssp {
82; FNOBUILTIN: @sqrtf_
83; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
84 %1 = call float @sqrtf(float 3.000000e+00)
85 ret float %1
86}
87declare float @sqrtf(float)
88
89; Shouldn't fold because of -fno-builtin
90define float @sinf_() nounwind uwtable ssp {
91; FNOBUILTIN: @sinf_
92; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
93 %1 = call float @sinf(float 3.000000e+00)
94 ret float %1
95}
96declare float @sinf(float)
97
98; Shouldn't fold because of -fno-builtin
99define double @tan_() nounwind uwtable ssp {
100; FNOBUILTIN: @tan_
101; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
102 %1 = call double @tan(double 3.000000e+00)
103 ret double %1
104}
105
106; Shouldn't fold because of -fno-builtin
107define double @tanh_() nounwind uwtable ssp {
108; FNOBUILTIN: @tanh_
109; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
110 %1 = call double @tanh(double 3.000000e+00)
111 ret double %1
112}
113declare double @tanh(double)
114
115; Shouldn't fold because of -fno-builtin
116define double @pow_() nounwind uwtable ssp {
117; FNOBUILTIN: @pow_
118; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
119 %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
120 ret double %1
121}
122declare double @pow(double, double)
123
124; Shouldn't fold because of -fno-builtin
125define double @fmod_() nounwind uwtable ssp {
126; FNOBUILTIN: @fmod_
127; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
128 %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
129 ret double %1
130}
131declare double @fmod(double, double)
132
133; Shouldn't fold because of -fno-builtin
134define double @atan2_() nounwind uwtable ssp {
135; FNOBUILTIN: @atan2_
136; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
137 %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
138 ret double %1
139}
140declare double @atan2(double, double)