1 ; Test rounding functions for z196 and above.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 \
4 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-SCALAR %s
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 \
6 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-VECTOR %s
9 declare float @llvm.rint.f32(float %f)
10 define float @f1(float %f) {
12 ; CHECK: fiebr %f0, 0, %f0
14 %res = call float @llvm.rint.f32(float %f)
19 declare double @llvm.rint.f64(double %f)
20 define double @f2(double %f) {
22 ; CHECK-SCALAR: fidbr %f0, 0, %f0
23 ; CHECK-VECTOR: fidbra %f0, 0, %f0, 0
25 %res = call double @llvm.rint.f64(double %f)
30 declare fp128 @llvm.rint.f128(fp128 %f)
31 define void @f3(ptr %ptr) {
33 ; CHECK: fixbr %f0, 0, %f0
35 %src = load fp128, ptr %ptr
36 %res = call fp128 @llvm.rint.f128(fp128 %src)
37 store fp128 %res, ptr %ptr
41 ; Test nearbyint for f32.
42 declare float @llvm.nearbyint.f32(float %f)
43 define float @f4(float %f) {
45 ; CHECK: fiebra %f0, 0, %f0, 4
47 %res = call float @llvm.nearbyint.f32(float %f)
51 ; Test nearbyint for f64.
52 declare double @llvm.nearbyint.f64(double %f)
53 define double @f5(double %f) {
55 ; CHECK: fidbra %f0, 0, %f0, 4
57 %res = call double @llvm.nearbyint.f64(double %f)
61 ; Test nearbyint for f128.
62 declare fp128 @llvm.nearbyint.f128(fp128 %f)
63 define void @f6(ptr %ptr) {
65 ; CHECK: fixbra %f0, 0, %f0, 4
67 %src = load fp128, ptr %ptr
68 %res = call fp128 @llvm.nearbyint.f128(fp128 %src)
69 store fp128 %res, ptr %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(ptr %ptr) {
97 ; CHECK: fixbra %f0, 7, %f0, 4
99 %src = load fp128, ptr %ptr
100 %res = call fp128 @llvm.floor.f128(fp128 %src)
101 store fp128 %res, ptr %ptr
106 declare float @llvm.ceil.f32(float %f)
107 define float @f10(float %f) {
109 ; CHECK: fiebra %f0, 6, %f0, 4
111 %res = call float @llvm.ceil.f32(float %f)
116 declare double @llvm.ceil.f64(double %f)
117 define double @f11(double %f) {
119 ; CHECK: fidbra %f0, 6, %f0, 4
121 %res = call double @llvm.ceil.f64(double %f)
125 ; Test ceil for f128.
126 declare fp128 @llvm.ceil.f128(fp128 %f)
127 define void @f12(ptr %ptr) {
129 ; CHECK: fixbra %f0, 6, %f0, 4
131 %src = load fp128, ptr %ptr
132 %res = call fp128 @llvm.ceil.f128(fp128 %src)
133 store fp128 %res, ptr %ptr
137 ; Test trunc for f32.
138 declare float @llvm.trunc.f32(float %f)
139 define float @f13(float %f) {
141 ; CHECK: fiebra %f0, 5, %f0, 4
143 %res = call float @llvm.trunc.f32(float %f)
147 ; Test trunc for f64.
148 declare double @llvm.trunc.f64(double %f)
149 define double @f14(double %f) {
151 ; CHECK: fidbra %f0, 5, %f0, 4
153 %res = call double @llvm.trunc.f64(double %f)
157 ; Test trunc for f128.
158 declare fp128 @llvm.trunc.f128(fp128 %f)
159 define void @f15(ptr %ptr) {
161 ; CHECK: fixbra %f0, 5, %f0, 4
163 %src = load fp128, ptr %ptr
164 %res = call fp128 @llvm.trunc.f128(fp128 %src)
165 store fp128 %res, ptr %ptr
169 ; Test round for f32.
170 declare float @llvm.round.f32(float %f)
171 define float @f16(float %f) {
173 ; CHECK: fiebra %f0, 1, %f0, 4
175 %res = call float @llvm.round.f32(float %f)
179 ; Test round for f64.
180 declare double @llvm.round.f64(double %f)
181 define double @f17(double %f) {
183 ; CHECK: fidbra %f0, 1, %f0, 4
185 %res = call double @llvm.round.f64(double %f)
189 ; Test round for f128.
190 declare fp128 @llvm.round.f128(fp128 %f)
191 define void @f18(ptr %ptr) {
193 ; CHECK: fixbra %f0, 1, %f0, 4
195 %src = load fp128, ptr %ptr
196 %res = call fp128 @llvm.round.f128(fp128 %src)
197 store fp128 %res, ptr %ptr