Fix some issues with Mips16 floating when certain intrinsics are present.
[oota-llvm.git] / test / CodeGen / Mips / fp16instrinsmc.ll
1 ; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=pic < %s | FileCheck %s -check-prefix=pic
2
3 @x = global float 1.500000e+00, align 4
4 @xn = global float -1.900000e+01, align 4
5 @negone = global float -1.000000e+00, align 4
6 @one = global float 1.000000e+00, align 4
7 @xd = global double 0x40048B0A8EA4481E, align 8
8 @xdn = global double 0xC0311F9ADD373963, align 8
9 @negoned = global double -1.000000e+00, align 8
10 @oned = global float 1.000000e+00, align 4
11 @y = common global float 0.000000e+00, align 4
12 @yd = common global double 0.000000e+00, align 8
13
14 ; Function Attrs: nounwind
15 define void @foo1() #0 {
16 entry:
17   %0 = load float* @x, align 4
18   %1 = load float* @one, align 4
19   %call = call float @copysignf(float %0, float %1) #2
20   store float %call, float* @y, align 4
21   ret void
22 }
23
24 ; Function Attrs: nounwind readnone
25 declare float @copysignf(float, float) #1
26
27 ; Function Attrs: nounwind
28 define void @foo2() #0 {
29 entry:
30   %0 = load float* @x, align 4
31   %1 = load float* @negone, align 4
32   %call = call float @copysignf(float %0, float %1) #2
33   store float %call, float* @y, align 4
34   ret void
35 }
36
37 ; Function Attrs: nounwind
38 define void @foo3() #0 {
39 entry:
40   %0 = load double* @xd, align 8
41   %1 = load float* @oned, align 4
42   %conv = fpext float %1 to double
43   %call = call double @copysign(double %0, double %conv) #2
44   store double %call, double* @yd, align 8
45   ret void
46 }
47
48 ; Function Attrs: nounwind readnone
49 declare double @copysign(double, double) #1
50
51 ; Function Attrs: nounwind
52 define void @foo4() #0 {
53 entry:
54   %0 = load double* @xd, align 8
55   %1 = load double* @negoned, align 8
56   %call = call double @copysign(double %0, double %1) #2
57   store double %call, double* @yd, align 8
58   ret void
59 }
60
61 ; Function Attrs: nounwind
62 define void @foo5() #0 {
63 entry:
64   %0 = load float* @xn, align 4
65   %call = call float @fabsf(float %0) #2
66   store float %call, float* @y, align 4
67   ret void
68 }
69
70 ; Function Attrs: nounwind readnone
71 declare float @fabsf(float) #1
72
73 ; Function Attrs: nounwind
74 define void @foo6() #0 {
75 entry:
76   %0 = load double* @xdn, align 8
77   %call = call double @fabs(double %0) #2
78   store double %call, double* @yd, align 8
79   ret void
80 }
81
82 ; Function Attrs: nounwind readnone
83 declare double @fabs(double) #1
84
85 ; Function Attrs: nounwind
86 define void @foo7() #0 {
87 entry:
88   %0 = load float* @x, align 4
89   %call = call float @sinf(float %0) #3
90 ;pic:   lw      ${{[0-9]+}}, %call16(sinf)(${{[0-9]+}})
91 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
92   store float %call, float* @y, align 4
93   ret void
94 }
95
96 ; Function Attrs: nounwind
97 declare float @sinf(float) #0
98
99 ; Function Attrs: nounwind
100 define void @foo8() #0 {
101 entry:
102   %0 = load double* @xd, align 8
103   %call = call double @sin(double %0) #3
104 ;pic:   lw      ${{[0-9]+}}, %call16(sin)(${{[0-9]+}})
105 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
106   store double %call, double* @yd, align 8
107   ret void
108 }
109
110 ; Function Attrs: nounwind
111 declare double @sin(double) #0
112
113 ; Function Attrs: nounwind
114 define void @foo9() #0 {
115 entry:
116   %0 = load float* @x, align 4
117   %call = call float @cosf(float %0) #3
118 ;pic:   lw      ${{[0-9]+}}, %call16(cosf)(${{[0-9]+}})
119 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
120   store float %call, float* @y, align 4
121   ret void
122 }
123
124 ; Function Attrs: nounwind
125 declare float @cosf(float) #0
126
127 ; Function Attrs: nounwind
128 define void @foo10() #0 {
129 entry:
130   %0 = load double* @xd, align 8
131   %call = call double @cos(double %0) #3
132 ;pic:   lw      ${{[0-9]+}}, %call16(cos)(${{[0-9]+}})
133 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
134   store double %call, double* @yd, align 8
135   ret void
136 }
137
138 ; Function Attrs: nounwind
139 declare double @cos(double) #0
140
141 ; Function Attrs: nounwind
142 define void @foo11() #0 {
143 entry:
144   %0 = load float* @x, align 4
145   %call = call float @sqrtf(float %0) #3
146 ;pic:   lw      ${{[0-9]+}}, %call16(sqrtf)(${{[0-9]+}})
147 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
148   store float %call, float* @y, align 4
149   ret void
150 }
151
152 ; Function Attrs: nounwind
153 declare float @sqrtf(float) #0
154
155 ; Function Attrs: nounwind
156 define void @foo12() #0 {
157 entry:
158   %0 = load double* @xd, align 8
159   %call = call double @sqrt(double %0) #3
160 ;pic:   lw      ${{[0-9]+}}, %call16(sqrt)(${{[0-9]+}})
161 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
162   store double %call, double* @yd, align 8
163   ret void
164 }
165
166 ; Function Attrs: nounwind
167 declare double @sqrt(double) #0
168
169 ; Function Attrs: nounwind
170 define void @foo13() #0 {
171 entry:
172   %0 = load float* @x, align 4
173   %call = call float @floorf(float %0) #2
174 ;pic:   lw      ${{[0-9]+}}, %call16(floorf)(${{[0-9]+}})
175 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
176   store float %call, float* @y, align 4
177   ret void
178 }
179
180 ; Function Attrs: nounwind readnone
181 declare float @floorf(float) #1
182
183 ; Function Attrs: nounwind
184 define void @foo14() #0 {
185 entry:
186   %0 = load double* @xd, align 8
187   %call = call double @floor(double %0) #2
188 ;pic:   lw      ${{[0-9]+}}, %call16(floor)(${{[0-9]+}})
189 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
190   store double %call, double* @yd, align 8
191   ret void
192 }
193
194 ; Function Attrs: nounwind readnone
195 declare double @floor(double) #1
196
197 ; Function Attrs: nounwind
198 define void @foo15() #0 {
199 entry:
200   %0 = load float* @x, align 4
201   %call = call float @nearbyintf(float %0) #2
202 ;pic:   lw      ${{[0-9]+}}, %call16(nearbyintf)(${{[0-9]+}})
203 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
204   store float %call, float* @y, align 4
205   ret void
206 }
207
208 ; Function Attrs: nounwind readnone
209 declare float @nearbyintf(float) #1
210
211 ; Function Attrs: nounwind
212 define void @foo16() #0 {
213 entry:
214   %0 = load double* @xd, align 8
215   %call = call double @nearbyint(double %0) #2
216 ;pic:   lw      ${{[0-9]+}}, %call16(nearbyint)(${{[0-9]+}})
217 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
218   store double %call, double* @yd, align 8
219   ret void
220 }
221
222 ; Function Attrs: nounwind readnone
223 declare double @nearbyint(double) #1
224
225 ; Function Attrs: nounwind
226 define void @foo17() #0 {
227 entry:
228   %0 = load float* @x, align 4
229   %call = call float @ceilf(float %0) #2
230 ;pic:   lw      ${{[0-9]+}}, %call16(ceilf)(${{[0-9]+}})
231 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
232   store float %call, float* @y, align 4
233   ret void
234 }
235
236 ; Function Attrs: nounwind readnone
237 declare float @ceilf(float) #1
238
239 ; Function Attrs: nounwind
240 define void @foo18() #0 {
241 entry:
242   %0 = load double* @xd, align 8
243   %call = call double @ceil(double %0) #2
244 ;pic:   lw      ${{[0-9]+}}, %call16(ceil)(${{[0-9]+}})
245 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
246   store double %call, double* @yd, align 8
247   ret void
248 }
249
250 ; Function Attrs: nounwind readnone
251 declare double @ceil(double) #1
252
253 ; Function Attrs: nounwind
254 define void @foo19() #0 {
255 entry:
256   %0 = load float* @x, align 4
257   %call = call float @rintf(float %0) #2
258 ;pic:   lw      ${{[0-9]+}}, %call16(rintf)(${{[0-9]+}})
259 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
260   store float %call, float* @y, align 4
261   ret void
262 }
263
264 ; Function Attrs: nounwind readnone
265 declare float @rintf(float) #1
266
267 ; Function Attrs: nounwind
268 define void @foo20() #0 {
269 entry:
270   %0 = load double* @xd, align 8
271   %call = call double @rint(double %0) #2
272 ;pic:   lw      ${{[0-9]+}}, %call16(rint)(${{[0-9]+}})
273 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
274   store double %call, double* @yd, align 8
275   ret void
276 }
277
278 ; Function Attrs: nounwind readnone
279 declare double @rint(double) #1
280
281 ; Function Attrs: nounwind
282 define void @foo21() #0 {
283 entry:
284   %0 = load float* @x, align 4
285   %call = call float @truncf(float %0) #2
286 ;pic:   lw      ${{[0-9]+}}, %call16(truncf)(${{[0-9]+}})
287 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
288   store float %call, float* @y, align 4
289   ret void
290 }
291
292 ; Function Attrs: nounwind readnone
293 declare float @truncf(float) #1
294
295 ; Function Attrs: nounwind
296 define void @foo22() #0 {
297 entry:
298   %0 = load double* @xd, align 8
299   %call = call double @trunc(double %0) #2
300 ;pic:   lw      ${{[0-9]+}}, %call16(trunc)(${{[0-9]+}})
301 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
302   store double %call, double* @yd, align 8
303   ret void
304 }
305
306 ; Function Attrs: nounwind readnone
307 declare double @trunc(double) #1
308
309 ; Function Attrs: nounwind
310 define void @foo23() #0 {
311 entry:
312   %0 = load float* @x, align 4
313   %call = call float @log2f(float %0) #3
314 ;pic:   lw      ${{[0-9]+}}, %call16(log2f)(${{[0-9]+}})
315 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
316   store float %call, float* @y, align 4
317   ret void
318 }
319
320 ; Function Attrs: nounwind
321 declare float @log2f(float) #0
322
323 ; Function Attrs: nounwind
324 define void @foo24() #0 {
325 entry:
326   %0 = load double* @xd, align 8
327   %call = call double @log2(double %0) #3
328 ;pic:   lw      ${{[0-9]+}}, %call16(log2)(${{[0-9]+}})
329 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
330   store double %call, double* @yd, align 8
331   ret void
332 }
333
334 ; Function Attrs: nounwind
335 declare double @log2(double) #0
336
337 ; Function Attrs: nounwind
338 define void @foo25() #0 {
339 entry:
340   %0 = load float* @x, align 4
341   %call = call float @exp2f(float %0) #3
342 ;pic:   lw      ${{[0-9]+}}, %call16(exp2f)(${{[0-9]+}})
343 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_sf_1)(${{[0-9]+}})
344   store float %call, float* @y, align 4
345   ret void
346 }
347
348 ; Function Attrs: nounwind
349 declare float @exp2f(float) #0
350
351 ; Function Attrs: nounwind
352 define void @foo26() #0 {
353 entry:
354   %0 = load double* @xd, align 8
355   %call = call double @exp2(double %0) #3
356 ;pic:   lw      ${{[0-9]+}}, %call16(exp2)(${{[0-9]+}})
357 ;pic:   lw      ${{[0-9]+}}, %got(__mips16_call_stub_df_2)(${{[0-9]+}})
358   store double %call, double* @yd, align 8
359   ret void
360 }
361
362 ; Function Attrs: nounwind
363 declare double @exp2(double) #0
364
365 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="true" }
366 attributes #1 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="true" }
367 attributes #2 = { nounwind readnone }
368 attributes #3 = { nounwind }