1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -early-cse -earlycse-debug-hash < %s | FileCheck %s
3
4declare float @truncf(float) #0
5declare float @llvm.trunc.f32(float) #0
6declare double @trunc(double) #0
7declare double @llvm.trunc.f64(double) #0
8
9define float @constant_fold_trunc_f32_01() #0 {
10; CHECK-LABEL: @constant_fold_trunc_f32_01(
11; CHECK-NEXT:    ret float 1.000000e+00
12;
13  %x = call float @truncf(float 1.25) #0
14  ret float %x
15}
16
17define float @constant_fold_trunc_f32_02() #0 {
18; CHECK-LABEL: @constant_fold_trunc_f32_02(
19; CHECK-NEXT:    ret float -1.000000e+00
20;
21  %x = call float @llvm.trunc.f32(float -1.25) #0
22  ret float %x
23}
24
25define float @constant_fold_trunc_f32_03() #0 {
26; CHECK-LABEL: @constant_fold_trunc_f32_03(
27; CHECK-NEXT:    ret float 1.000000e+00
28;
29  %x = call float @truncf(float 1.5) #0
30  ret float %x
31}
32
33define float @constant_fold_trunc_f32_04() #0 {
34; CHECK-LABEL: @constant_fold_trunc_f32_04(
35; CHECK-NEXT:    ret float -1.000000e+00
36;
37  %x = call float @llvm.trunc.f32(float -1.5) #0
38  ret float %x
39}
40
41define float @constant_fold_trunc_f32_05() #0 {
42; CHECK-LABEL: @constant_fold_trunc_f32_05(
43; CHECK-NEXT:    ret float 2.000000e+00
44;
45  %x = call float @truncf(float 2.75) #0
46  ret float %x
47}
48
49define float @constant_fold_trunc_f32_06() #0 {
50; CHECK-LABEL: @constant_fold_trunc_f32_06(
51; CHECK-NEXT:    ret float -2.000000e+00
52;
53  %x = call float @llvm.trunc.f32(float -2.75) #0
54  ret float %x
55}
56
57define double @constant_fold_trunc_f64_01() #0 {
58; CHECK-LABEL: @constant_fold_trunc_f64_01(
59; CHECK-NEXT:    ret double 1.000000e+00
60;
61  %x = call double @trunc(double 1.3) #0
62  ret double %x
63}
64
65define double @constant_fold_trunc_f64_02() #0 {
66; CHECK-LABEL: @constant_fold_trunc_f64_02(
67; CHECK-NEXT:    ret double -1.000000e+00
68;
69  %x = call double @llvm.trunc.f64(double -1.3) #0
70  ret double %x
71}
72
73define double @constant_fold_trunc_f64_03() #0 {
74; CHECK-LABEL: @constant_fold_trunc_f64_03(
75; CHECK-NEXT:    ret double 1.000000e+00
76;
77  %x = call double @trunc(double 1.5) #0
78  ret double %x
79}
80
81define double @constant_fold_trunc_f64_04() #0 {
82; CHECK-LABEL: @constant_fold_trunc_f64_04(
83; CHECK-NEXT:    ret double -1.000000e+00
84;
85  %x = call double @llvm.trunc.f64(double -1.5) #0
86  ret double %x
87}
88
89define double @constant_fold_trunc_f64_05() #0 {
90; CHECK-LABEL: @constant_fold_trunc_f64_05(
91; CHECK-NEXT:    ret double 2.000000e+00
92;
93  %x = call double @trunc(double 2.7) #0
94  ret double %x
95}
96
97define double @constant_fold_trunc_f64_06() #0 {
98; CHECK-LABEL: @constant_fold_trunc_f64_06(
99; CHECK-NEXT:    ret double -2.000000e+00
100;
101  %x = call double @llvm.trunc.f64(double -2.7) #0
102  ret double %x
103}
104
105attributes #0 = { nounwind readnone }
106