1 ; Test rounding functions for z14 and above.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
6 declare float @llvm.rint.f32(float %f)
7 define float @f1(float %f) {
9 ; CHECK: fiebra %f0, 0, %f0, 0
11 %res = call float @llvm.rint.f32(float %f)
16 declare double @llvm.rint.f64(double %f)
17 define double @f2(double %f) {
19 ; CHECK: fidbra %f0, 0, %f0, 0
21 %res = call double @llvm.rint.f64(double %f)
26 declare fp128 @llvm.rint.f128(fp128 %f)
27 define void @f3(fp128 *%ptr) {
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)
33 %src = load fp128, fp128 *%ptr
34 %res = call fp128 @llvm.rint.f128(fp128 %src)
35 store fp128 %res, fp128 *%ptr
39 ; Test nearbyint for f32.
40 declare float @llvm.nearbyint.f32(float %f)
41 define float @f4(float %f) {
43 ; CHECK: fiebra %f0, 0, %f0, 4
45 %res = call float @llvm.nearbyint.f32(float %f)
49 ; Test nearbyint for f64.
50 declare double @llvm.nearbyint.f64(double %f)
51 define double @f5(double %f) {
53 ; CHECK: fidbra %f0, 0, %f0, 4
55 %res = call double @llvm.nearbyint.f64(double %f)
59 ; Test nearbyint for f128.
60 declare fp128 @llvm.nearbyint.f128(fp128 %f)
61 define void @f6(fp128 *%ptr) {
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)
67 %src = load fp128, fp128 *%ptr
68 %res = call fp128 @llvm.nearbyint.f128(fp128 %src)
69 store fp128 %res, fp128 *%ptr
74 declare float @llvm.floor.f32(float %f)
75 define float @f7(float %f) {
77 ; CHECK: fiebra %f0, 7, %f0, 4
79 %res = call float @llvm.floor.f32(float %f)
84 declare double @llvm.floor.f64(double %f)
85 define double @f8(double %f) {
87 ; CHECK: fidbra %f0, 7, %f0, 4
89 %res = call double @llvm.floor.f64(double %f)
93 ; Test floor for f128.
94 declare fp128 @llvm.floor.f128(fp128 %f)
95 define void @f9(fp128 *%ptr) {
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)
101 %src = load fp128, fp128 *%ptr
102 %res = call fp128 @llvm.floor.f128(fp128 %src)
103 store fp128 %res, fp128 *%ptr
108 declare float @llvm.ceil.f32(float %f)
109 define float @f10(float %f) {
111 ; CHECK: fiebra %f0, 6, %f0, 4
113 %res = call float @llvm.ceil.f32(float %f)
118 declare double @llvm.ceil.f64(double %f)
119 define double @f11(double %f) {
121 ; CHECK: fidbra %f0, 6, %f0, 4
123 %res = call double @llvm.ceil.f64(double %f)
127 ; Test ceil for f128.
128 declare fp128 @llvm.ceil.f128(fp128 %f)
129 define void @f12(fp128 *%ptr) {
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)
135 %src = load fp128, fp128 *%ptr
136 %res = call fp128 @llvm.ceil.f128(fp128 %src)
137 store fp128 %res, fp128 *%ptr
141 ; Test trunc for f32.
142 declare float @llvm.trunc.f32(float %f)
143 define float @f13(float %f) {
145 ; CHECK: fiebra %f0, 5, %f0, 4
147 %res = call float @llvm.trunc.f32(float %f)
151 ; Test trunc for f64.
152 declare double @llvm.trunc.f64(double %f)
153 define double @f14(double %f) {
155 ; CHECK: fidbra %f0, 5, %f0, 4
157 %res = call double @llvm.trunc.f64(double %f)
161 ; Test trunc for f128.
162 declare fp128 @llvm.trunc.f128(fp128 %f)
163 define void @f15(fp128 *%ptr) {
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)
169 %src = load fp128, fp128 *%ptr
170 %res = call fp128 @llvm.trunc.f128(fp128 %src)
171 store fp128 %res, fp128 *%ptr
175 ; Test round for f32.
176 declare float @llvm.round.f32(float %f)
177 define float @f16(float %f) {
179 ; CHECK: fiebra %f0, 1, %f0, 4
181 %res = call float @llvm.round.f32(float %f)
185 ; Test round for f64.
186 declare double @llvm.round.f64(double %f)
187 define double @f17(double %f) {
189 ; CHECK: fidbra %f0, 1, %f0, 4
191 %res = call double @llvm.round.f64(double %f)
195 ; Test round for f128.
196 declare fp128 @llvm.round.f128(fp128 %f)
197 define void @f18(fp128 *%ptr) {
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)
203 %src = load fp128, fp128 *%ptr
204 %res = call fp128 @llvm.round.f128(fp128 %src)
205 store fp128 %res, fp128 *%ptr