1 ; RUN: opt -S -instcombine < %s | FileCheck %s
3 declare float @llvm.round.f32(float) #0
4 declare double @llvm.round.f64(double) #0
6 ; CHECK-LABEL: @constant_fold_round_f32_01
7 ; CHECK-NEXT: ret float 1.000000e+00
8 define float @constant_fold_round_f32_01() #0 {
9 %x = call float @llvm.round.f32(float 1.25) #0
13 ; CHECK-LABEL: @constant_fold_round_f32_02
14 ; CHECK-NEXT: ret float -1.000000e+00
15 define float @constant_fold_round_f32_02() #0 {
16 %x = call float @llvm.round.f32(float -1.25) #0
20 ; CHECK-LABEL: @constant_fold_round_f32_03
21 ; CHECK-NEXT: ret float 2.000000e+00
22 define float @constant_fold_round_f32_03() #0 {
23 %x = call float @llvm.round.f32(float 1.5) #0
27 ; CHECK-LABEL: @constant_fold_round_f32_04
28 ; CHECK-NEXT: ret float -2.000000e+00
29 define float @constant_fold_round_f32_04() #0 {
30 %x = call float @llvm.round.f32(float -1.5) #0
34 ; CHECK-LABEL: @constant_fold_round_f32_05
35 ; CHECK-NEXT: ret float 3.000000e+00
36 define float @constant_fold_round_f32_05() #0 {
37 %x = call float @llvm.round.f32(float 2.75) #0
41 ; CHECK-LABEL: @constant_fold_round_f32_06
42 ; CHECK-NEXT: ret float -3.000000e+00
43 define float @constant_fold_round_f32_06() #0 {
44 %x = call float @llvm.round.f32(float -2.75) #0
48 ; CHECK-LABEL: @constant_fold_round_f64_01
49 ; CHECK-NEXT: ret double 1.000000e+00
50 define double @constant_fold_round_f64_01() #0 {
51 %x = call double @llvm.round.f64(double 1.3) #0
55 ; CHECK-LABEL: @constant_fold_round_f64_02
56 ; CHECK-NEXT: ret double -1.000000e+00
57 define double @constant_fold_round_f64_02() #0 {
58 %x = call double @llvm.round.f64(double -1.3) #0
62 ; CHECK-LABEL: @constant_fold_round_f64_03
63 ; CHECK-NEXT: ret double 2.000000e+00
64 define double @constant_fold_round_f64_03() #0 {
65 %x = call double @llvm.round.f64(double 1.5) #0
69 ; CHECK-LABEL: @constant_fold_round_f64_04
70 ; CHECK-NEXT: ret double -2.000000e+00
71 define double @constant_fold_round_f64_04() #0 {
72 %x = call double @llvm.round.f64(double -1.5) #0
76 ; CHECK-LABEL: @constant_fold_round_f64_05
77 ; CHECK-NEXT: ret double 3.000000e+00
78 define double @constant_fold_round_f64_05() #0 {
79 %x = call double @llvm.round.f64(double 2.7) #0
83 ; CHECK-LABEL: @constant_fold_round_f64_06
84 ; CHECK-NEXT: ret double -3.000000e+00
85 define double @constant_fold_round_f64_06() #0 {
86 %x = call double @llvm.round.f64(double -2.7) #0
90 attributes #0 = { nounwind readnone }