1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify %s | FileCheck %s
4 define float @sitofp_floor(i32 %arg) {
5 ; CHECK-LABEL: @sitofp_floor(
6 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
7 ; CHECK-NEXT: ret float [[CVT]]
9 %cvt = sitofp i32 %arg to float
10 %round = call float @llvm.floor.f32(float %cvt)
14 define float @uitofp_floor(i32 %arg) {
15 ; CHECK-LABEL: @uitofp_floor(
16 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
17 ; CHECK-NEXT: ret float [[CVT]]
19 %cvt = uitofp i32 %arg to float
20 %round = call float @llvm.floor.f32(float %cvt)
24 define float @sitofp_trunc(i32 %arg) {
25 ; CHECK-LABEL: @sitofp_trunc(
26 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
27 ; CHECK-NEXT: ret float [[CVT]]
29 %cvt = sitofp i32 %arg to float
30 %round = call float @llvm.trunc.f32(float %cvt)
34 define float @uitofp_trunc(i32 %arg) {
35 ; CHECK-LABEL: @uitofp_trunc(
36 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
37 ; CHECK-NEXT: ret float [[CVT]]
39 %cvt = uitofp i32 %arg to float
40 %round = call float @llvm.trunc.f32(float %cvt)
44 define float @sitofp_ceil(i32 %arg) {
45 ; CHECK-LABEL: @sitofp_ceil(
46 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
47 ; CHECK-NEXT: ret float [[CVT]]
49 %cvt = sitofp i32 %arg to float
50 %round = call float @llvm.ceil.f32(float %cvt)
54 define float @uitofp_ceil(i32 %arg) {
55 ; CHECK-LABEL: @uitofp_ceil(
56 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
57 ; CHECK-NEXT: ret float [[CVT]]
59 %cvt = uitofp i32 %arg to float
60 %round = call float @llvm.ceil.f32(float %cvt)
64 define float @sitofp_round(i32 %arg) {
65 ; CHECK-LABEL: @sitofp_round(
66 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
67 ; CHECK-NEXT: ret float [[CVT]]
69 %cvt = sitofp i32 %arg to float
70 %round = call float @llvm.round.f32(float %cvt)
74 define float @uitofp_round(i32 %arg) {
75 ; CHECK-LABEL: @uitofp_round(
76 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
77 ; CHECK-NEXT: ret float [[CVT]]
79 %cvt = uitofp i32 %arg to float
80 %round = call float @llvm.round.f32(float %cvt)
84 define float @uitofp_roundeven(i32 %arg) {
85 ; CHECK-LABEL: @uitofp_roundeven(
86 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
87 ; CHECK-NEXT: ret float [[CVT]]
89 %cvt = uitofp i32 %arg to float
90 %round = call float @llvm.roundeven.f32(float %cvt)
94 define float @sitofp_nearbyint(i32 %arg) {
95 ; CHECK-LABEL: @sitofp_nearbyint(
96 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
97 ; CHECK-NEXT: ret float [[CVT]]
99 %cvt = sitofp i32 %arg to float
100 %nearbyint = call float @llvm.nearbyint.f32(float %cvt)
104 define float @uitofp_nearbyint(i32 %arg) {
105 ; CHECK-LABEL: @uitofp_nearbyint(
106 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
107 ; CHECK-NEXT: ret float [[CVT]]
109 %cvt = uitofp i32 %arg to float
110 %nearbyint = call float @llvm.nearbyint.f32(float %cvt)
114 define float @sitofp_rint(i32 %arg) {
115 ; CHECK-LABEL: @sitofp_rint(
116 ; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
117 ; CHECK-NEXT: ret float [[CVT]]
119 %cvt = sitofp i32 %arg to float
120 %rint = call float @llvm.rint.f32(float %cvt)
124 define float @uitofp_rint(i32 %arg) {
125 ; CHECK-LABEL: @uitofp_rint(
126 ; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
127 ; CHECK-NEXT: ret float [[CVT]]
129 %cvt = uitofp i32 %arg to float
130 %rint = call float @llvm.rint.f32(float %cvt)
134 define float @floor_trunc(float %x) {
135 ; CHECK-LABEL: @floor_trunc(
136 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
137 ; CHECK-NEXT: ret float [[A]]
139 %a = call float @llvm.floor.f32(float %x)
140 %r = call float @llvm.trunc.f32(float %a)
144 define float @floor_ceil(float %x) {
145 ; CHECK-LABEL: @floor_ceil(
146 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
147 ; CHECK-NEXT: ret float [[A]]
149 %a = call float @llvm.floor.f32(float %x)
150 %r = call float @llvm.ceil.f32(float %a)
154 define float @floor_round(float %x) {
155 ; CHECK-LABEL: @floor_round(
156 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
157 ; CHECK-NEXT: ret float [[A]]
159 %a = call float @llvm.floor.f32(float %x)
160 %r = call float @llvm.round.f32(float %a)
164 define float @floor_roundeven(float %x) {
165 ; CHECK-LABEL: @floor_roundeven(
166 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
167 ; CHECK-NEXT: ret float [[A]]
169 %a = call float @llvm.floor.f32(float %x)
170 %r = call float @llvm.roundeven.f32(float %a)
174 define float @floor_nearbyint(float %x) {
175 ; CHECK-LABEL: @floor_nearbyint(
176 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
177 ; CHECK-NEXT: ret float [[A]]
179 %a = call float @llvm.floor.f32(float %x)
180 %r = call float @llvm.nearbyint.f32(float %a)
184 define float @floor_rint(float %x) {
185 ; CHECK-LABEL: @floor_rint(
186 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
187 ; CHECK-NEXT: ret float [[A]]
189 %a = call float @llvm.floor.f32(float %x)
190 %r = call float @llvm.rint.f32(float %a)
194 define float @trunc_floor(float %x) {
195 ; CHECK-LABEL: @trunc_floor(
196 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
197 ; CHECK-NEXT: ret float [[A]]
199 %a = call float @llvm.trunc.f32(float %x)
200 %r = call float @llvm.floor.f32(float %a)
204 define float @trunc_ceil(float %x) {
205 ; CHECK-LABEL: @trunc_ceil(
206 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
207 ; CHECK-NEXT: ret float [[A]]
209 %a = call float @llvm.trunc.f32(float %x)
210 %r = call float @llvm.ceil.f32(float %a)
214 define float @trunc_round(float %x) {
215 ; CHECK-LABEL: @trunc_round(
216 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
217 ; CHECK-NEXT: ret float [[A]]
219 %a = call float @llvm.trunc.f32(float %x)
220 %r = call float @llvm.round.f32(float %a)
224 define float @trunc_roundeven(float %x) {
225 ; CHECK-LABEL: @trunc_roundeven(
226 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
227 ; CHECK-NEXT: ret float [[A]]
229 %a = call float @llvm.trunc.f32(float %x)
230 %r = call float @llvm.roundeven.f32(float %a)
234 define float @trunc_nearbyint(float %x) {
235 ; CHECK-LABEL: @trunc_nearbyint(
236 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
237 ; CHECK-NEXT: ret float [[A]]
239 %a = call float @llvm.trunc.f32(float %x)
240 %r = call float @llvm.nearbyint.f32(float %a)
244 define float @trunc_rint(float %x) {
245 ; CHECK-LABEL: @trunc_rint(
246 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
247 ; CHECK-NEXT: ret float [[A]]
249 %a = call float @llvm.trunc.f32(float %x)
250 %r = call float @llvm.rint.f32(float %a)
254 define float @ceil_floor(float %x) {
255 ; CHECK-LABEL: @ceil_floor(
256 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
257 ; CHECK-NEXT: ret float [[A]]
259 %a = call float @llvm.ceil.f32(float %x)
260 %r = call float @llvm.floor.f32(float %a)
264 define float @ceil_trunc(float %x) {
265 ; CHECK-LABEL: @ceil_trunc(
266 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
267 ; CHECK-NEXT: ret float [[A]]
269 %a = call float @llvm.ceil.f32(float %x)
270 %r = call float @llvm.trunc.f32(float %a)
274 define float @ceil_round(float %x) {
275 ; CHECK-LABEL: @ceil_round(
276 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
277 ; CHECK-NEXT: ret float [[A]]
279 %a = call float @llvm.ceil.f32(float %x)
280 %r = call float @llvm.round.f32(float %a)
284 define float @ceil_roundeven(float %x) {
285 ; CHECK-LABEL: @ceil_roundeven(
286 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
287 ; CHECK-NEXT: ret float [[A]]
289 %a = call float @llvm.ceil.f32(float %x)
290 %r = call float @llvm.roundeven.f32(float %a)
294 define float @ceil_nearbyint(float %x) {
295 ; CHECK-LABEL: @ceil_nearbyint(
296 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
297 ; CHECK-NEXT: ret float [[A]]
299 %a = call float @llvm.ceil.f32(float %x)
300 %r = call float @llvm.nearbyint.f32(float %a)
304 define float @ceil_rint(float %x) {
305 ; CHECK-LABEL: @ceil_rint(
306 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
307 ; CHECK-NEXT: ret float [[A]]
309 %a = call float @llvm.ceil.f32(float %x)
310 %r = call float @llvm.rint.f32(float %a)
314 define float @round_floor(float %x) {
315 ; CHECK-LABEL: @round_floor(
316 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
317 ; CHECK-NEXT: ret float [[A]]
319 %a = call float @llvm.round.f32(float %x)
320 %r = call float @llvm.floor.f32(float %a)
324 define float @round_trunc(float %x) {
325 ; CHECK-LABEL: @round_trunc(
326 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
327 ; CHECK-NEXT: ret float [[A]]
329 %a = call float @llvm.round.f32(float %x)
330 %r = call float @llvm.trunc.f32(float %a)
334 define float @round_ceil(float %x) {
335 ; CHECK-LABEL: @round_ceil(
336 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
337 ; CHECK-NEXT: ret float [[A]]
339 %a = call float @llvm.round.f32(float %x)
340 %r = call float @llvm.ceil.f32(float %a)
344 define float @round_roundeven(float %x) {
345 ; CHECK-LABEL: @round_roundeven(
346 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
347 ; CHECK-NEXT: ret float [[A]]
349 %a = call float @llvm.round.f32(float %x)
350 %r = call float @llvm.roundeven.f32(float %a)
354 define float @round_nearbyint(float %x) {
355 ; CHECK-LABEL: @round_nearbyint(
356 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
357 ; CHECK-NEXT: ret float [[A]]
359 %a = call float @llvm.round.f32(float %x)
360 %r = call float @llvm.nearbyint.f32(float %a)
364 define float @round_rint(float %x) {
365 ; CHECK-LABEL: @round_rint(
366 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
367 ; CHECK-NEXT: ret float [[A]]
369 %a = call float @llvm.round.f32(float %x)
370 %r = call float @llvm.rint.f32(float %a)
374 define float @roundeven_floor(float %x) {
375 ; CHECK-LABEL: @roundeven_floor(
376 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
377 ; CHECK-NEXT: ret float [[A]]
379 %a = call float @llvm.roundeven.f32(float %x)
380 %r = call float @llvm.floor.f32(float %a)
384 define float @roundeven_trunc(float %x) {
385 ; CHECK-LABEL: @roundeven_trunc(
386 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
387 ; CHECK-NEXT: ret float [[A]]
389 %a = call float @llvm.roundeven.f32(float %x)
390 %r = call float @llvm.trunc.f32(float %a)
394 define float @roundeven_ceil(float %x) {
395 ; CHECK-LABEL: @roundeven_ceil(
396 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
397 ; CHECK-NEXT: ret float [[A]]
399 %a = call float @llvm.roundeven.f32(float %x)
400 %r = call float @llvm.ceil.f32(float %a)
404 define float @roundeven_round(float %x) {
405 ; CHECK-LABEL: @roundeven_round(
406 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
407 ; CHECK-NEXT: ret float [[A]]
409 %a = call float @llvm.roundeven.f32(float %x)
410 %r = call float @llvm.round.f32(float %a)
414 define float @roundeven_nearbyint(float %x) {
415 ; CHECK-LABEL: @roundeven_nearbyint(
416 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
417 ; CHECK-NEXT: ret float [[A]]
419 %a = call float @llvm.roundeven.f32(float %x)
420 %r = call float @llvm.nearbyint.f32(float %a)
424 define float @roundeven_rint(float %x) {
425 ; CHECK-LABEL: @roundeven_rint(
426 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
427 ; CHECK-NEXT: ret float [[A]]
429 %a = call float @llvm.roundeven.f32(float %x)
430 %r = call float @llvm.rint.f32(float %a)
434 define float @nearbyint_floor(float %x) {
435 ; CHECK-LABEL: @nearbyint_floor(
436 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
437 ; CHECK-NEXT: ret float [[A]]
439 %a = call float @llvm.nearbyint.f32(float %x)
440 %r = call float @llvm.floor.f32(float %a)
444 define float @nearbyint_trunc(float %x) {
445 ; CHECK-LABEL: @nearbyint_trunc(
446 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
447 ; CHECK-NEXT: ret float [[A]]
449 %a = call float @llvm.nearbyint.f32(float %x)
450 %r = call float @llvm.trunc.f32(float %a)
454 define float @nearbyint_ceil(float %x) {
455 ; CHECK-LABEL: @nearbyint_ceil(
456 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
457 ; CHECK-NEXT: ret float [[A]]
459 %a = call float @llvm.nearbyint.f32(float %x)
460 %r = call float @llvm.ceil.f32(float %a)
464 define float @nearbyint_round(float %x) {
465 ; CHECK-LABEL: @nearbyint_round(
466 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
467 ; CHECK-NEXT: ret float [[A]]
469 %a = call float @llvm.nearbyint.f32(float %x)
470 %r = call float @llvm.round.f32(float %a)
474 define float @nearbyint_roundeven(float %x) {
475 ; CHECK-LABEL: @nearbyint_roundeven(
476 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
477 ; CHECK-NEXT: ret float [[A]]
479 %a = call float @llvm.nearbyint.f32(float %x)
480 %r = call float @llvm.roundeven.f32(float %a)
484 define float @nearbyint_rint(float %x) {
485 ; CHECK-LABEL: @nearbyint_rint(
486 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
487 ; CHECK-NEXT: ret float [[A]]
489 %a = call float @llvm.nearbyint.f32(float %x)
490 %r = call float @llvm.rint.f32(float %a)
494 define float @rint_floor(float %x) {
495 ; CHECK-LABEL: @rint_floor(
496 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
497 ; CHECK-NEXT: ret float [[A]]
499 %a = call float @llvm.rint.f32(float %x)
500 %r = call float @llvm.floor.f32(float %a)
504 define float @rint_trunc(float %x) {
505 ; CHECK-LABEL: @rint_trunc(
506 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
507 ; CHECK-NEXT: ret float [[A]]
509 %a = call float @llvm.rint.f32(float %x)
510 %r = call float @llvm.trunc.f32(float %a)
514 define float @rint_ceil(float %x) {
515 ; CHECK-LABEL: @rint_ceil(
516 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
517 ; CHECK-NEXT: ret float [[A]]
519 %a = call float @llvm.rint.f32(float %x)
520 %r = call float @llvm.ceil.f32(float %a)
524 define float @rint_round(float %x) {
525 ; CHECK-LABEL: @rint_round(
526 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
527 ; CHECK-NEXT: ret float [[A]]
529 %a = call float @llvm.rint.f32(float %x)
530 %r = call float @llvm.round.f32(float %a)
534 define float @rint_roundeven(float %x) {
535 ; CHECK-LABEL: @rint_roundeven(
536 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
537 ; CHECK-NEXT: ret float [[A]]
539 %a = call float @llvm.rint.f32(float %x)
540 %r = call float @llvm.roundeven.f32(float %a)
544 define float @rint_nearbyint(float %x) {
545 ; CHECK-LABEL: @rint_nearbyint(
546 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
547 ; CHECK-NEXT: ret float [[A]]
549 %a = call float @llvm.rint.f32(float %x)
550 %r = call float @llvm.nearbyint.f32(float %a)
554 declare float @llvm.floor.f32(float) #0
555 declare float @llvm.trunc.f32(float) #0
556 declare float @llvm.ceil.f32(float) #0
557 declare float @llvm.round.f32(float) #0
558 declare float @llvm.roundeven.f32(float) #0
559 declare float @llvm.nearbyint.f32(float) #0
560 declare float @llvm.rint.f32(float) #0
562 attributes #0 = { nounwind readnone speculatable }