• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test rounding functions for z14 and above.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
4
5; Test rint for f32.
6declare float @llvm.rint.f32(float %f)
7define float @f1(float %f) {
8; CHECK-LABEL: f1:
9; CHECK: fiebra %f0, 0, %f0, 0
10; CHECK: br %r14
11  %res = call float @llvm.rint.f32(float %f)
12  ret float %res
13}
14
15; Test rint for f64.
16declare double @llvm.rint.f64(double %f)
17define double @f2(double %f) {
18; CHECK-LABEL: f2:
19; CHECK: fidbra %f0, 0, %f0, 0
20; CHECK: br %r14
21  %res = call double @llvm.rint.f64(double %f)
22  ret double %res
23}
24
25; Test rint for f128.
26declare fp128 @llvm.rint.f128(fp128 %f)
27define void @f3(fp128 *%ptr) {
28; CHECK-LABEL: f3:
29; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
30; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 0, 0
31; CHECK: vst [[RES]], 0(%r2)
32; CHECK: br %r14
33  %src = load fp128, fp128 *%ptr
34  %res = call fp128 @llvm.rint.f128(fp128 %src)
35  store fp128 %res, fp128 *%ptr
36  ret void
37}
38
39; Test nearbyint for f32.
40declare float @llvm.nearbyint.f32(float %f)
41define float @f4(float %f) {
42; CHECK-LABEL: f4:
43; CHECK: fiebra %f0, 0, %f0, 4
44; CHECK: br %r14
45  %res = call float @llvm.nearbyint.f32(float %f)
46  ret float %res
47}
48
49; Test nearbyint for f64.
50declare double @llvm.nearbyint.f64(double %f)
51define double @f5(double %f) {
52; CHECK-LABEL: f5:
53; CHECK: fidbra %f0, 0, %f0, 4
54; CHECK: br %r14
55  %res = call double @llvm.nearbyint.f64(double %f)
56  ret double %res
57}
58
59; Test nearbyint for f128.
60declare fp128 @llvm.nearbyint.f128(fp128 %f)
61define void @f6(fp128 *%ptr) {
62; CHECK-LABEL: f6:
63; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
64; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 0
65; CHECK: vst [[RES]], 0(%r2)
66; CHECK: br %r14
67  %src = load fp128, fp128 *%ptr
68  %res = call fp128 @llvm.nearbyint.f128(fp128 %src)
69  store fp128 %res, fp128 *%ptr
70  ret void
71}
72
73; Test floor for f32.
74declare float @llvm.floor.f32(float %f)
75define float @f7(float %f) {
76; CHECK-LABEL: f7:
77; CHECK: fiebra %f0, 7, %f0, 4
78; CHECK: br %r14
79  %res = call float @llvm.floor.f32(float %f)
80  ret float %res
81}
82
83; Test floor for f64.
84declare double @llvm.floor.f64(double %f)
85define double @f8(double %f) {
86; CHECK-LABEL: f8:
87; CHECK: fidbra %f0, 7, %f0, 4
88; CHECK: br %r14
89  %res = call double @llvm.floor.f64(double %f)
90  ret double %res
91}
92
93; Test floor for f128.
94declare fp128 @llvm.floor.f128(fp128 %f)
95define void @f9(fp128 *%ptr) {
96; CHECK-LABEL: f9:
97; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
98; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 7
99; CHECK: vst [[RES]], 0(%r2)
100; CHECK: br %r14
101  %src = load fp128, fp128 *%ptr
102  %res = call fp128 @llvm.floor.f128(fp128 %src)
103  store fp128 %res, fp128 *%ptr
104  ret void
105}
106
107; Test ceil for f32.
108declare float @llvm.ceil.f32(float %f)
109define float @f10(float %f) {
110; CHECK-LABEL: f10:
111; CHECK: fiebra %f0, 6, %f0, 4
112; CHECK: br %r14
113  %res = call float @llvm.ceil.f32(float %f)
114  ret float %res
115}
116
117; Test ceil for f64.
118declare double @llvm.ceil.f64(double %f)
119define double @f11(double %f) {
120; CHECK-LABEL: f11:
121; CHECK: fidbra %f0, 6, %f0, 4
122; CHECK: br %r14
123  %res = call double @llvm.ceil.f64(double %f)
124  ret double %res
125}
126
127; Test ceil for f128.
128declare fp128 @llvm.ceil.f128(fp128 %f)
129define void @f12(fp128 *%ptr) {
130; CHECK-LABEL: f12:
131; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
132; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 6
133; CHECK: vst [[RES]], 0(%r2)
134; CHECK: br %r14
135  %src = load fp128, fp128 *%ptr
136  %res = call fp128 @llvm.ceil.f128(fp128 %src)
137  store fp128 %res, fp128 *%ptr
138  ret void
139}
140
141; Test trunc for f32.
142declare float @llvm.trunc.f32(float %f)
143define float @f13(float %f) {
144; CHECK-LABEL: f13:
145; CHECK: fiebra %f0, 5, %f0, 4
146; CHECK: br %r14
147  %res = call float @llvm.trunc.f32(float %f)
148  ret float %res
149}
150
151; Test trunc for f64.
152declare double @llvm.trunc.f64(double %f)
153define double @f14(double %f) {
154; CHECK-LABEL: f14:
155; CHECK: fidbra %f0, 5, %f0, 4
156; CHECK: br %r14
157  %res = call double @llvm.trunc.f64(double %f)
158  ret double %res
159}
160
161; Test trunc for f128.
162declare fp128 @llvm.trunc.f128(fp128 %f)
163define void @f15(fp128 *%ptr) {
164; CHECK-LABEL: f15:
165; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
166; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 5
167; CHECK: vst [[RES]], 0(%r2)
168; CHECK: br %r14
169  %src = load fp128, fp128 *%ptr
170  %res = call fp128 @llvm.trunc.f128(fp128 %src)
171  store fp128 %res, fp128 *%ptr
172  ret void
173}
174
175; Test round for f32.
176declare float @llvm.round.f32(float %f)
177define float @f16(float %f) {
178; CHECK-LABEL: f16:
179; CHECK: fiebra %f0, 1, %f0, 4
180; CHECK: br %r14
181  %res = call float @llvm.round.f32(float %f)
182  ret float %res
183}
184
185; Test round for f64.
186declare double @llvm.round.f64(double %f)
187define double @f17(double %f) {
188; CHECK-LABEL: f17:
189; CHECK: fidbra %f0, 1, %f0, 4
190; CHECK: br %r14
191  %res = call double @llvm.round.f64(double %f)
192  ret double %res
193}
194
195; Test round for f128.
196declare fp128 @llvm.round.f128(fp128 %f)
197define void @f18(fp128 *%ptr) {
198; CHECK-LABEL: f18:
199; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
200; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 1
201; CHECK: vst [[RES]], 0(%r2)
202; CHECK: br %r14
203  %src = load fp128, fp128 *%ptr
204  %res = call fp128 @llvm.round.f128(fp128 %src)
205  store fp128 %res, fp128 *%ptr
206  ret void
207}
208