1 ; RUN: opt -S -passes=early-cse -earlycse-debug-hash < %s | FileCheck %s
3 declare float @roundf(float) #0
4 declare float @llvm.round.f32(float)
5 declare double @round(double) #0
6 declare double @llvm.round.f64(double)
8 ; CHECK-LABEL: @constant_fold_round_f32_01
9 ; CHECK-NEXT: ret float 1.000000e+00
10 define float @constant_fold_round_f32_01() #0 {
11 %x = call float @roundf(float 1.25) #0
15 ; CHECK-LABEL: @constant_fold_round_f32_02
16 ; CHECK-NEXT: ret float -1.000000e+00
17 define float @constant_fold_round_f32_02() #0 {
18 %x = call float @llvm.round.f32(float -1.25) #0
22 ; CHECK-LABEL: @constant_fold_round_f32_03
23 ; CHECK-NEXT: ret float 2.000000e+00
24 define float @constant_fold_round_f32_03() #0 {
25 %x = call float @roundf(float 1.5) #0
29 ; CHECK-LABEL: @constant_fold_round_f32_04
30 ; CHECK-NEXT: ret float -2.000000e+00
31 define float @constant_fold_round_f32_04() #0 {
32 %x = call float @llvm.round.f32(float -1.5) #0
36 ; CHECK-LABEL: @constant_fold_round_f32_05
37 ; CHECK-NEXT: ret float 3.000000e+00
38 define float @constant_fold_round_f32_05() #0 {
39 %x = call float @roundf(float 2.75) #0
43 ; CHECK-LABEL: @constant_fold_round_f32_06
44 ; CHECK-NEXT: ret float -3.000000e+00
45 define float @constant_fold_round_f32_06() #0 {
46 %x = call float @llvm.round.f32(float -2.75) #0
50 ; CHECK-LABEL: @constant_fold_round_f64_01
51 ; CHECK-NEXT: ret double 1.000000e+00
52 define double @constant_fold_round_f64_01() #0 {
53 %x = call double @round(double 1.3) #0
57 ; CHECK-LABEL: @constant_fold_round_f64_02
58 ; CHECK-NEXT: ret double -1.000000e+00
59 define double @constant_fold_round_f64_02() #0 {
60 %x = call double @llvm.round.f64(double -1.3) #0
64 ; CHECK-LABEL: @constant_fold_round_f64_03
65 ; CHECK-NEXT: ret double 2.000000e+00
66 define double @constant_fold_round_f64_03() #0 {
67 %x = call double @round(double 1.5) #0
71 ; CHECK-LABEL: @constant_fold_round_f64_04
72 ; CHECK-NEXT: ret double -2.000000e+00
73 define double @constant_fold_round_f64_04() #0 {
74 %x = call double @llvm.round.f64(double -1.5) #0
78 ; CHECK-LABEL: @constant_fold_round_f64_05
79 ; CHECK-NEXT: ret double 3.000000e+00
80 define double @constant_fold_round_f64_05() #0 {
81 %x = call double @round(double 2.7) #0
85 ; CHECK-LABEL: @constant_fold_round_f64_06
86 ; CHECK-NEXT: ret double -3.000000e+00
87 define double @constant_fold_round_f64_06() #0 {
88 %x = call double @llvm.round.f64(double -2.7) #0
92 attributes #0 = { nounwind readnone willreturn }