Fix the testcase in r246790
[oota-llvm.git] / test / CodeGen / AArch64 / round-conv.ll
1 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s --check-prefix=CHECK-INEXACT
2 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0 -enable-unsafe-fp-math | FileCheck %s --check-prefix=CHECK-FAST
3 ; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefix=CHECK-FAST
4
5 ; CHECK-INEXACT-LABEL: testmsws:
6 ; CHECK-INEXACT: fcvtms w0, s0
7 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
8
9 ; CHECK-FAST-LABEL: testmsws:
10 ; CHECK-FAST: fcvtms w0, s0
11 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
12 define i32 @testmsws(float %a) {
13 entry:
14   %call = call float @floorf(float %a) nounwind readnone
15   %conv = fptosi float %call to i32
16   ret i32 %conv
17 }
18
19 ; CHECK-INEXACT-LABEL: testmsxs:
20 ; CHECK-INEXACT: fcvtms x0, s0
21 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
22
23 ; CHECK-FAST-LABEL: testmsxs:
24 ; CHECK-FAST: fcvtms x0, s0
25 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
26 define i64 @testmsxs(float %a) {
27 entry:
28   %call = call float @floorf(float %a) nounwind readnone
29   %conv = fptosi float %call to i64
30   ret i64 %conv
31 }
32
33 ; CHECK-INEXACT-LABEL: testmswd:
34 ; CHECK-INEXACT: fcvtms w0, d0
35 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
36
37 ; CHECK-FAST-LABEL: testmswd:
38 ; CHECK-FAST: fcvtms w0, d0
39 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
40 define i32 @testmswd(double %a) {
41 entry:
42   %call = call double @floor(double %a) nounwind readnone
43   %conv = fptosi double %call to i32
44   ret i32 %conv
45 }
46
47 ; CHECK-INEXACT-LABEL: testmsxd:
48 ; CHECK-INEXACT: fcvtms x0, d0
49 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
50
51 ; CHECK-FAST-LABEL: testmsxd:
52 ; CHECK-FAST: fcvtms x0, d0
53 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
54 define i64 @testmsxd(double %a) {
55 entry:
56   %call = call double @floor(double %a) nounwind readnone
57   %conv = fptosi double %call to i64
58   ret i64 %conv
59 }
60
61 ; CHECK-INEXACT-LABEL: testmuws:
62 ; CHECK-INEXACT: fcvtmu w0, s0
63 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
64
65 ; CHECK-FAST-LABEL: testmuws:
66 ; CHECK-FAST: fcvtmu w0, s0
67 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
68 define i32 @testmuws(float %a) {
69 entry:
70   %call = call float @floorf(float %a) nounwind readnone
71   %conv = fptoui float %call to i32
72   ret i32 %conv
73 }
74
75 ; CHECK-INEXACT-LABEL: testmuxs:
76 ; CHECK-INEXACT: fcvtmu x0, s0
77 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
78
79 ; CHECK-FAST-LABEL: testmuxs:
80 ; CHECK-FAST: fcvtmu x0, s0
81 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
82 define i64 @testmuxs(float %a) {
83 entry:
84   %call = call float @floorf(float %a) nounwind readnone
85   %conv = fptoui float %call to i64
86   ret i64 %conv
87 }
88
89 ; CHECK-INEXACT-LABEL: testmuwd:
90 ; CHECK-INEXACT: fcvtmu w0, d0
91 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
92
93 ; CHECK-FAST-LABEL: testmuwd:
94 ; CHECK-FAST: fcvtmu w0, d0
95 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
96 define i32 @testmuwd(double %a) {
97 entry:
98   %call = call double @floor(double %a) nounwind readnone
99   %conv = fptoui double %call to i32
100   ret i32 %conv
101 }
102
103 ; CHECK-INEXACT-LABEL: testmuxd:
104 ; CHECK-INEXACT: fcvtmu x0, d0
105 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
106
107 ; CHECK-FAST-LABEL: testmuxd:
108 ; CHECK-FAST: fcvtmu x0, d0
109 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
110 define i64 @testmuxd(double %a) {
111 entry:
112   %call = call double @floor(double %a) nounwind readnone
113   %conv = fptoui double %call to i64
114   ret i64 %conv
115 }
116
117 ; CHECK-INEXACT-LABEL: testpsws:
118 ; CHECK-INEXACT: fcvtps w0, s0
119 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
120
121 ; CHECK-FAST-LABEL: testpsws:
122 ; CHECK-FAST: fcvtps w0, s0
123 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
124 define i32 @testpsws(float %a) {
125 entry:
126   %call = call float @ceilf(float %a) nounwind readnone
127   %conv = fptosi float %call to i32
128   ret i32 %conv
129 }
130
131 ; CHECK-INEXACT-LABEL: testpsxs:
132 ; CHECK-INEXACT: fcvtps x0, s0
133 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
134
135 ; CHECK-FAST-LABEL: testpsxs:
136 ; CHECK-FAST: fcvtps x0, s0
137 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
138 define i64 @testpsxs(float %a) {
139 entry:
140   %call = call float @ceilf(float %a) nounwind readnone
141   %conv = fptosi float %call to i64
142   ret i64 %conv
143 }
144
145 ; CHECK-INEXACT-LABEL: testpswd:
146 ; CHECK-INEXACT: fcvtps w0, d0
147 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
148
149 ; CHECK-FAST-LABEL: testpswd:
150 ; CHECK-FAST: fcvtps w0, d0
151 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
152 define i32 @testpswd(double %a) {
153 entry:
154   %call = call double @ceil(double %a) nounwind readnone
155   %conv = fptosi double %call to i32
156   ret i32 %conv
157 }
158
159 ; CHECK-INEXACT-LABEL: testpsxd:
160 ; CHECK-INEXACT: fcvtps x0, d0
161 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
162
163 ; CHECK-FAST-LABEL: testpsxd:
164 ; CHECK-FAST: fcvtps x0, d0
165 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
166 define i64 @testpsxd(double %a) {
167 entry:
168   %call = call double @ceil(double %a) nounwind readnone
169   %conv = fptosi double %call to i64
170   ret i64 %conv
171 }
172
173 ; CHECK-INEXACT-LABEL: testpuws:
174 ; CHECK-INEXACT: fcvtpu w0, s0
175 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
176
177 ; CHECK-FAST-LABEL: testpuws:
178 ; CHECK-FAST: fcvtpu w0, s0
179 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
180 define i32 @testpuws(float %a) {
181 entry:
182   %call = call float @ceilf(float %a) nounwind readnone
183   %conv = fptoui float %call to i32
184   ret i32 %conv
185 }
186
187 ; CHECK-INEXACT-LABEL: testpuxs:
188 ; CHECK-INEXACT: fcvtpu x0, s0
189 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
190
191 ; CHECK-FAST-LABEL: testpuxs:
192 ; CHECK-FAST: fcvtpu x0, s0
193 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
194 define i64 @testpuxs(float %a) {
195 entry:
196   %call = call float @ceilf(float %a) nounwind readnone
197   %conv = fptoui float %call to i64
198   ret i64 %conv
199 }
200
201 ; CHECK-INEXACT-LABEL: testpuwd:
202 ; CHECK-INEXACT: fcvtpu w0, d0
203 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
204
205 ; CHECK-FAST-LABEL: testpuwd:
206 ; CHECK-FAST: fcvtpu w0, d0
207 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
208 define i32 @testpuwd(double %a) {
209 entry:
210   %call = call double @ceil(double %a) nounwind readnone
211   %conv = fptoui double %call to i32
212   ret i32 %conv
213 }
214
215 ; CHECK-INEXACT-LABEL: testpuxd:
216 ; CHECK-INEXACT: fcvtpu x0, d0
217 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
218
219 ; CHECK-FAST-LABEL: testpuxd:
220 ; CHECK-FAST: fcvtpu x0, d0
221 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
222 define i64 @testpuxd(double %a) {
223 entry:
224   %call = call double @ceil(double %a) nounwind readnone
225   %conv = fptoui double %call to i64
226   ret i64 %conv
227 }
228
229 ; CHECK-INEXACT-LABEL: testzsws:
230 ; CHECK-INEXACT: fcvtzs w0, s0
231 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
232
233 ; CHECK-FAST-LABEL: testzsws:
234 ; CHECK-FAST: fcvtzs w0, s0
235 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
236 define i32 @testzsws(float %a) {
237 entry:
238   %call = call float @truncf(float %a) nounwind readnone
239   %conv = fptosi float %call to i32
240   ret i32 %conv
241 }
242
243 ; CHECK-INEXACT-LABEL: testzsxs:
244 ; CHECK-INEXACT: fcvtzs x0, s0
245 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
246
247 ; CHECK-FAST-LABEL: testzsxs:
248 ; CHECK-FAST: fcvtzs x0, s0
249 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
250 define i64 @testzsxs(float %a) {
251 entry:
252   %call = call float @truncf(float %a) nounwind readnone
253   %conv = fptosi float %call to i64
254   ret i64 %conv
255 }
256
257 ; CHECK-INEXACT-LABEL: testzswd:
258 ; CHECK-INEXACT: fcvtzs w0, d0
259 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
260
261 ; CHECK-FAST-LABEL: testzswd:
262 ; CHECK-FAST: fcvtzs w0, d0
263 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
264 define i32 @testzswd(double %a) {
265 entry:
266   %call = call double @trunc(double %a) nounwind readnone
267   %conv = fptosi double %call to i32
268   ret i32 %conv
269 }
270
271 ; CHECK-INEXACT-LABEL: testzsxd:
272 ; CHECK-INEXACT: fcvtzs x0, d0
273 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
274
275 ; CHECK-FAST-LABEL: testzsxd:
276 ; CHECK-FAST: fcvtzs x0, d0
277 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
278 define i64 @testzsxd(double %a) {
279 entry:
280   %call = call double @trunc(double %a) nounwind readnone
281   %conv = fptosi double %call to i64
282   ret i64 %conv
283 }
284
285 ; CHECK-INEXACT-LABEL: testzuws:
286 ; CHECK-INEXACT: fcvtzu w0, s0
287 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
288
289 ; CHECK-FAST-LABEL: testzuws:
290 ; CHECK-FAST: fcvtzu w0, s0
291 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
292 define i32 @testzuws(float %a) {
293 entry:
294   %call = call float @truncf(float %a) nounwind readnone
295   %conv = fptoui float %call to i32
296   ret i32 %conv
297 }
298
299 ; CHECK-INEXACT-LABEL: testzuxs:
300 ; CHECK-INEXACT: fcvtzu x0, s0
301 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
302
303 ; CHECK-FAST-LABEL: testzuxs:
304 ; CHECK-FAST: fcvtzu x0, s0
305 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
306 define i64 @testzuxs(float %a) {
307 entry:
308   %call = call float @truncf(float %a) nounwind readnone
309   %conv = fptoui float %call to i64
310   ret i64 %conv
311 }
312
313 ; CHECK-INEXACT-LABEL: testzuwd:
314 ; CHECK-INEXACT: fcvtzu w0, d0
315 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
316
317 ; CHECK-FAST-LABEL: testzuwd:
318 ; CHECK-FAST: fcvtzu w0, d0
319 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
320 define i32 @testzuwd(double %a) {
321 entry:
322   %call = call double @trunc(double %a) nounwind readnone
323   %conv = fptoui double %call to i32
324   ret i32 %conv
325 }
326
327 ; CHECK-INEXACT-LABEL: testzuxd:
328 ; CHECK-INEXACT: fcvtzu x0, d0
329 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
330
331 ; CHECK-FAST-LABEL: testzuxd:
332 ; CHECK-FAST: fcvtzu x0, d0
333 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
334 define i64 @testzuxd(double %a) {
335 entry:
336   %call = call double @trunc(double %a) nounwind readnone
337   %conv = fptoui double %call to i64
338   ret i64 %conv
339 }
340
341 ; CHECK-INEXACT-LABEL: testasws:
342 ; CHECK-INEXACT: fcvtas w0, s0
343 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
344
345 ; CHECK-FAST-LABEL: testasws:
346 ; CHECK-FAST: fcvtas w0, s0
347 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
348 define i32 @testasws(float %a) {
349 entry:
350   %call = call float @roundf(float %a) nounwind readnone
351   %conv = fptosi float %call to i32
352   ret i32 %conv
353 }
354
355 ; CHECK-INEXACT-LABEL: testasxs:
356 ; CHECK-INEXACT: fcvtas x0, s0
357 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
358
359 ; CHECK-FAST-LABEL: testasxs:
360 ; CHECK-FAST: fcvtas x0, s0
361 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
362 define i64 @testasxs(float %a) {
363 entry:
364   %call = call float @roundf(float %a) nounwind readnone
365   %conv = fptosi float %call to i64
366   ret i64 %conv
367 }
368
369 ; CHECK-INEXACT-LABEL: testaswd:
370 ; CHECK-INEXACT: fcvtas w0, d0
371 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
372
373 ; CHECK-FAST-LABEL: testaswd:
374 ; CHECK-FAST: fcvtas w0, d0
375 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
376 define i32 @testaswd(double %a) {
377 entry:
378   %call = call double @round(double %a) nounwind readnone
379   %conv = fptosi double %call to i32
380   ret i32 %conv
381 }
382
383 ; CHECK-INEXACT-LABEL: testasxd:
384 ; CHECK-INEXACT: fcvtas x0, d0
385 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
386
387 ; CHECK-FAST-LABEL: testasxd:
388 ; CHECK-FAST: fcvtas x0, d0
389 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
390 define i64 @testasxd(double %a) {
391 entry:
392   %call = call double @round(double %a) nounwind readnone
393   %conv = fptosi double %call to i64
394   ret i64 %conv
395 }
396
397 ; CHECK-INEXACT-LABEL: testauws:
398 ; CHECK-INEXACT: fcvtau w0, s0
399 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
400
401 ; CHECK-FAST-LABEL: testauws:
402 ; CHECK-FAST: fcvtau w0, s0
403 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
404 define i32 @testauws(float %a) {
405 entry:
406   %call = call float @roundf(float %a) nounwind readnone
407   %conv = fptoui float %call to i32
408   ret i32 %conv
409 }
410
411 ; CHECK-INEXACT-LABEL: testauxs:
412 ; CHECK-INEXACT: fcvtau x0, s0
413 ; CHECK-INEXACT: frintx {{s[0-9]+}}, s0
414
415 ; CHECK-FAST-LABEL: testauxs:
416 ; CHECK-FAST: fcvtau x0, s0
417 ; CHECK-FAST-NOT: frintx {{s[0-9]+}}, s0
418 define i64 @testauxs(float %a) {
419 entry:
420   %call = call float @roundf(float %a) nounwind readnone
421   %conv = fptoui float %call to i64
422   ret i64 %conv
423 }
424
425 ; CHECK-INEXACT-LABEL: testauwd:
426 ; CHECK-INEXACT: fcvtau w0, d0
427 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
428
429 ; CHECK-FAST-LABEL: testauwd:
430 ; CHECK-FAST: fcvtau w0, d0
431 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
432 define i32 @testauwd(double %a) {
433 entry:
434   %call = call double @round(double %a) nounwind readnone
435   %conv = fptoui double %call to i32
436   ret i32 %conv
437 }
438
439 ; CHECK-INEXACT-LABEL: testauxd:
440 ; CHECK-INEXACT: fcvtau x0, d0
441 ; CHECK-INEXACT: frintx {{d[0-9]+}}, d0
442
443 ; CHECK-FAST-LABEL: testauxd:
444 ; CHECK-FAST: fcvtau x0, d0
445 ; CHECK-FAST-NOT: frintx {{d[0-9]+}}, d0
446 define i64 @testauxd(double %a) {
447 entry:
448   %call = call double @round(double %a) nounwind readnone
449   %conv = fptoui double %call to i64
450   ret i64 %conv
451 }
452
453
454 declare float @floorf(float) nounwind readnone
455 declare double @floor(double) nounwind readnone
456 declare float @ceilf(float) nounwind readnone
457 declare double @ceil(double) nounwind readnone
458 declare float @truncf(float) nounwind readnone
459 declare double @trunc(double) nounwind readnone
460 declare float @roundf(float) nounwind readnone
461 declare double @round(double) nounwind readnone