1; RUN: opt -O2 -S -mtriple=i386-pc-win32 < %s | FileCheck %s -check-prefix=WIN32
2; RUN: opt -O2 -S -mtriple=x86_64-pc-win32 < %s | FileCheck %s -check-prefix=WIN64
3; RUN: opt -O2 -S -mtriple=i386-pc-mingw32 < %s | FileCheck %s -check-prefix=MINGW32
4; RUN: opt -O2 -S -mtriple=x86_64-pc-mingw32 < %s | FileCheck %s -check-prefix=MINGW64
5
6; x86 win32 msvcrt does not provide entry points for single-precision libm.
7; x86-64 win32 msvcrt does (except for fabsf)
8; msvcrt does not provide C99 math, but mingw32 does.
9
10declare double @acos(double %x)
11define float @float_acos(float %x) nounwind readnone {
12; WIN32-LABEL: @float_acos(
13; WIN32-NOT: float @acosf
14; WIN32: double @acos
15    %1 = fpext float %x to double
16    %2 = call double @acos(double %1)
17    %3 = fptrunc double %2 to float
18    ret float %3
19}
20
21declare double @asin(double %x)
22define float @float_asin(float %x) nounwind readnone {
23; WIN32-LABEL: @float_asin(
24; WIN32-NOT: float @asinf
25; WIN32: double @asin
26    %1 = fpext float %x to double
27    %2 = call double @asin(double %1)
28    %3 = fptrunc double %2 to float
29    ret float %3
30}
31
32declare double @atan(double %x)
33define float @float_atan(float %x) nounwind readnone {
34; WIN32-LABEL: @float_atan(
35; WIN32-NOT: float @atanf
36; WIN32: double @atan
37    %1 = fpext float %x to double
38    %2 = call double @atan(double %1)
39    %3 = fptrunc double %2 to float
40    ret float %3
41}
42
43declare double @atan2(double %x, double %y)
44define float @float_atan2(float %x, float %y) nounwind readnone {
45; WIN32-LABEL: @float_atan2(
46; WIN32-NOT: float @atan2f
47; WIN32: double @atan2
48    %1 = fpext float %x to double
49    %2 = fpext float %y to double
50    %3 = call double @atan2(double %1, double %2)
51    %4 = fptrunc double %3 to float
52    ret float %4
53}
54
55declare double @ceil(double %x)
56define float @float_ceil(float %x) nounwind readnone {
57; WIN32-LABEL: @float_ceil(
58; WIN32-NOT: float @ceilf
59; WIN32: double @ceil
60; WIN64-LABEL: @float_ceil(
61; WIN64: float @ceilf
62; WIN64-NOT: double @ceil
63; MINGW32-LABEL: @float_ceil(
64; MINGW32: float @ceilf
65; MINGW32-NOT: double @ceil
66; MINGW64-LABEL: @float_ceil(
67; MINGW64: float @ceilf
68; MINGW64-NOT: double @ceil
69    %1 = fpext float %x to double
70    %2 = call double @ceil(double %1)
71    %3 = fptrunc double %2 to float
72    ret float %3
73}
74
75declare double @_copysign(double %x)
76define float @float_copysign(float %x) nounwind readnone {
77; WIN32-LABEL: @float_copysign(
78; WIN32-NOT: float @copysignf
79; WIN32-NOT: float @_copysignf
80; WIN32: double @_copysign
81    %1 = fpext float %x to double
82    %2 = call double @_copysign(double %1)
83    %3 = fptrunc double %2 to float
84    ret float %3
85}
86
87declare double @cos(double %x)
88define float @float_cos(float %x) nounwind readnone {
89; WIN32-LABEL: @float_cos(
90; WIN32-NOT: float @cosf
91; WIN32: double @cos
92    %1 = fpext float %x to double
93    %2 = call double @cos(double %1)
94    %3 = fptrunc double %2 to float
95    ret float %3
96}
97
98declare double @cosh(double %x)
99define float @float_cosh(float %x) nounwind readnone {
100; WIN32-LABEL: @float_cosh(
101; WIN32-NOT: float @coshf
102; WIN32: double @cosh
103    %1 = fpext float %x to double
104    %2 = call double @cosh(double %1)
105    %3 = fptrunc double %2 to float
106    ret float %3
107}
108
109declare double @exp(double %x, double %y)
110define float @float_exp(float %x, float %y) nounwind readnone {
111; WIN32-LABEL: @float_exp(
112; WIN32-NOT: float @expf
113; WIN32: double @exp
114    %1 = fpext float %x to double
115    %2 = fpext float %y to double
116    %3 = call double @exp(double %1, double %2)
117    %4 = fptrunc double %3 to float
118    ret float %4
119}
120
121declare double @fabs(double %x, double %y)
122define float @float_fabs(float %x, float %y) nounwind readnone {
123; WIN32-LABEL: @float_fabs(
124; WIN32-NOT: float @fabsf
125; WIN32: double @fabs
126; WIN64-LABEL: @float_fabs(
127; WIN64-NOT: float @fabsf
128; WIN64: double @fabs
129    %1 = fpext float %x to double
130    %2 = fpext float %y to double
131    %3 = call double @fabs(double %1, double %2)
132    %4 = fptrunc double %3 to float
133    ret float %4
134}
135
136declare double @floor(double %x)
137define float @float_floor(float %x) nounwind readnone {
138; WIN32-LABEL: @float_floor(
139; WIN32-NOT: float @floorf
140; WIN32: double @floor
141; WIN64-LABEL: @float_floor(
142; WIN64: float @floorf
143; WIN64-NOT: double @floor
144; MINGW32-LABEL: @float_floor(
145; MINGW32: float @floorf
146; MINGW32-NOT: double @floor
147; MINGW64-LABEL: @float_floor(
148; MINGW64: float @floorf
149; MINGW64-NOT: double @floor
150    %1 = fpext float %x to double
151    %2 = call double @floor(double %1)
152    %3 = fptrunc double %2 to float
153    ret float %3
154}
155
156declare double @fmod(double %x, double %y)
157define float @float_fmod(float %x, float %y) nounwind readnone {
158; WIN32-LABEL: @float_fmod(
159; WIN32-NOT: float @fmodf
160; WIN32: double @fmod
161    %1 = fpext float %x to double
162    %2 = fpext float %y to double
163    %3 = call double @fmod(double %1, double %2)
164    %4 = fptrunc double %3 to float
165    ret float %4
166}
167
168declare double @log(double %x)
169define float @float_log(float %x) nounwind readnone {
170; WIN32-LABEL: @float_log(
171; WIN32-NOT: float @logf
172; WIN32: double @log
173    %1 = fpext float %x to double
174    %2 = call double @log(double %1)
175    %3 = fptrunc double %2 to float
176    ret float %3
177}
178
179declare double @pow(double %x, double %y)
180define float @float_pow(float %x, float %y) nounwind readnone {
181; WIN32-LABEL: @float_pow(
182; WIN32-NOT: float @powf
183; WIN32: double @pow
184    %1 = fpext float %x to double
185    %2 = fpext float %y to double
186    %3 = call double @pow(double %1, double %2)
187    %4 = fptrunc double %3 to float
188    ret float %4
189}
190
191declare double @sin(double %x)
192define float @float_sin(float %x) nounwind readnone {
193; WIN32-LABEL: @float_sin(
194; WIN32-NOT: float @sinf
195; WIN32: double @sin
196    %1 = fpext float %x to double
197    %2 = call double @sin(double %1)
198    %3 = fptrunc double %2 to float
199    ret float %3
200}
201
202declare double @sinh(double %x)
203define float @float_sinh(float %x) nounwind readnone {
204; WIN32-LABEL: @float_sinh(
205; WIN32-NOT: float @sinhf
206; WIN32: double @sinh
207    %1 = fpext float %x to double
208    %2 = call double @sinh(double %1)
209    %3 = fptrunc double %2 to float
210    ret float %3
211}
212
213declare double @sqrt(double %x)
214define float @float_sqrt(float %x) nounwind readnone {
215; WIN32-LABEL: @float_sqrt(
216; WIN32-NOT: float @sqrtf
217; WIN32: double @sqrt
218; WIN64-LABEL: @float_sqrt(
219; WIN64: float @sqrtf
220; WIN64-NOT: double @sqrt
221; MINGW32-LABEL: @float_sqrt(
222; MINGW32: float @sqrtf
223; MINGW32-NOT: double @sqrt
224; MINGW64-LABEL: @float_sqrt(
225; MINGW64: float @sqrtf
226; MINGW64-NOT: double @sqrt
227    %1 = fpext float %x to double
228    %2 = call double @sqrt(double %1)
229    %3 = fptrunc double %2 to float
230    ret float %3
231}
232
233declare double @tan(double %x)
234define float @float_tan(float %x) nounwind readnone {
235; WIN32-LABEL: @float_tan(
236; WIN32-NOT: float @tanf
237; WIN32: double @tan
238    %1 = fpext float %x to double
239    %2 = call double @tan(double %1)
240    %3 = fptrunc double %2 to float
241    ret float %3
242}
243
244declare double @tanh(double %x)
245define float @float_tanh(float %x) nounwind readnone {
246; WIN32-LABEL: @float_tanh(
247; WIN32-NOT: float @tanhf
248; WIN32: double @tanh
249    %1 = fpext float %x to double
250    %2 = call double @tanh(double %1)
251    %3 = fptrunc double %2 to float
252    ret float %3
253}
254
255; win32 does not have round; mingw32 does
256declare double @round(double %x)
257define float @float_round(float %x) nounwind readnone {
258; WIN32-LABEL: @float_round(
259; WIN32-NOT: float @roundf
260; WIN32: double @round
261; WIN64-LABEL: @float_round(
262; WIN64-NOT: float @roundf
263; WIN64: double @round
264; MINGW32-LABEL: @float_round(
265; MINGW32: float @roundf
266; MINGW32-NOT: double @round
267; MINGW64-LABEL: @float_round(
268; MINGW64: float @roundf
269; MINGW64-NOT: double @round
270    %1 = fpext float %x to double
271    %2 = call double @round(double %1)
272    %3 = fptrunc double %2 to float
273    ret float %3
274}
275
276declare float @powf(float, float)
277; win32 lacks sqrtf&fabsf, win64 lacks fabsf
278define float @float_powsqrt(float %x) nounwind readnone {
279; WIN32-LABEL: @float_powsqrt(
280; WIN32-NOT: float @sqrtf
281; WIN32: float @powf
282; WIN64-LABEL: @float_powsqrt(
283; WIN64-NOT: float @sqrtf
284; WIN64: float @powf
285; MINGW32-LABEL: @float_powsqrt(
286; MINGW32: float @sqrtf
287; MINGW32: float @fabsf
288; MINGW32-NOT: float @powf
289; MINGW64-LABEL: @float_powsqrt(
290; MINGW64: float @sqrtf
291; MINGW64: float @fabsf
292; MINGW64-NOT: float @powf
293    %1 = call float @powf(float %x, float 0.5)
294    ret float %1
295}
296