1 ; Test vector minimum on z14.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
5 declare double @fmin(double, double)
6 declare double @llvm.minnum.f64(double, double)
7 declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>)
8 declare double @llvm.minimum.f64(double, double)
9 declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
11 declare float @fminf(float, float)
12 declare float @llvm.minnum.f32(float, float)
13 declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>)
14 declare float @llvm.minimum.f32(float, float)
15 declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>)
17 declare fp128 @fminl(fp128, fp128)
18 declare fp128 @llvm.minnum.f128(fp128, fp128)
19 declare fp128 @llvm.minimum.f128(fp128, fp128)
21 ; Test the fmin library function.
22 define double @f1(double %dummy, double %val1, double %val2) {
24 ; CHECK: wfmindb %f0, %f2, %f4, 4
26 %ret = call double @fmin(double %val1, double %val2) readnone
30 ; Test the f64 minnum intrinsic.
31 define double @f2(double %dummy, double %val1, double %val2) {
33 ; CHECK: wfmindb %f0, %f2, %f4, 4
35 %ret = call double @llvm.minnum.f64(double %val1, double %val2)
39 ; Test the f64 minimum intrinsic.
40 define double @f3(double %dummy, double %val1, double %val2) {
42 ; CHECK: wfmindb %f0, %f2, %f4, 1
44 %ret = call double @llvm.minimum.f64(double %val1, double %val2)
48 ; Test a f64 constant compare/select resulting in minnum.
49 define double @f4(double %dummy, double %val) {
51 ; CHECK: lzdr [[REG:%f[0-9]+]]
52 ; CHECK: wfmindb %f0, %f2, [[REG]], 4
54 %cmp = fcmp olt double %val, 0.0
55 %ret = select i1 %cmp, double %val, double 0.0
59 ; Test a f64 constant compare/select resulting in minimum.
60 define double @f5(double %dummy, double %val) {
62 ; CHECK: ltdbr %f1, %f2
63 ; CHECK-NEXT: ldr %f0, %f2
65 %cmp = fcmp ult double %val, 0.0
66 %ret = select i1 %cmp, double %val, double 0.0
70 ; Test the v2f64 minnum intrinsic.
71 define <2 x double> @f6(<2 x double> %dummy, <2 x double> %val1,
74 ; CHECK: vfmindb %v24, %v26, %v28, 4
76 %ret = call <2 x double> @llvm.minnum.v2f64(<2 x double> %val1, <2 x double> %val2)
80 ; Test the v2f64 minimum intrinsic.
81 define <2 x double> @f7(<2 x double> %dummy, <2 x double> %val1,
84 ; CHECK: vfmindb %v24, %v26, %v28, 1
86 %ret = call <2 x double> @llvm.minimum.v2f64(<2 x double> %val1, <2 x double> %val2)
90 ; Test the fminf library function.
91 define float @f11(float %dummy, float %val1, float %val2) {
93 ; CHECK: wfminsb %f0, %f2, %f4, 4
95 %ret = call float @fminf(float %val1, float %val2) readnone
99 ; Test the f32 minnum intrinsic.
100 define float @f12(float %dummy, float %val1, float %val2) {
102 ; CHECK: wfminsb %f0, %f2, %f4, 4
104 %ret = call float @llvm.minnum.f32(float %val1, float %val2)
108 ; Test the f32 minimum intrinsic.
109 define float @f13(float %dummy, float %val1, float %val2) {
111 ; CHECK: wfminsb %f0, %f2, %f4, 1
113 %ret = call float @llvm.minimum.f32(float %val1, float %val2)
117 ; Test a f32 constant compare/select resulting in minnum.
118 define float @f14(float %dummy, float %val) {
120 ; CHECK: lzer [[REG:%f[0-9]+]]
121 ; CHECK: wfminsb %f0, %f2, [[REG]], 4
123 %cmp = fcmp olt float %val, 0.0
124 %ret = select i1 %cmp, float %val, float 0.0
128 ; Test a f32 constant compare/select resulting in minimum.
129 define float @f15(float %dummy, float %val) {
131 ; CHECK: ltebr %f1, %f2
132 ; CHECK: ldr %f0, %f2
134 %cmp = fcmp ult float %val, 0.0
135 %ret = select i1 %cmp, float %val, float 0.0
139 ; Test the v4f32 minnum intrinsic.
140 define <4 x float> @f16(<4 x float> %dummy, <4 x float> %val1,
143 ; CHECK: vfminsb %v24, %v26, %v28, 4
145 %ret = call <4 x float> @llvm.minnum.v4f32(<4 x float> %val1, <4 x float> %val2)
149 ; Test the v4f32 minimum intrinsic.
150 define <4 x float> @f17(<4 x float> %dummy, <4 x float> %val1,
153 ; CHECK: vfminsb %v24, %v26, %v28, 1
155 %ret = call <4 x float> @llvm.minimum.v4f32(<4 x float> %val1, <4 x float> %val2)
159 ; Test the fminl library function.
160 define void @f21(ptr %ptr1, ptr %ptr2, ptr %dst) {
162 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
163 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
164 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
165 ; CHECK: vst [[RES]], 0(%r4)
167 %val1 = load fp128, ptr %ptr1
168 %val2 = load fp128, ptr %ptr2
169 %res = call fp128 @fminl(fp128 %val1, fp128 %val2) readnone
170 store fp128 %res, ptr %dst
174 ; Test the f128 minnum intrinsic.
175 define void @f22(ptr %ptr1, ptr %ptr2, ptr %dst) {
177 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
178 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
179 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
180 ; CHECK: vst [[RES]], 0(%r4)
182 %val1 = load fp128, ptr %ptr1
183 %val2 = load fp128, ptr %ptr2
184 %res = call fp128 @llvm.minnum.f128(fp128 %val1, fp128 %val2)
185 store fp128 %res, ptr %dst
189 ; Test the f128 minimum intrinsic.
190 define void @f23(ptr %ptr1, ptr %ptr2, ptr %dst) {
192 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
193 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
194 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 1
195 ; CHECK: vst [[RES]], 0(%r4)
197 %val1 = load fp128, ptr %ptr1
198 %val2 = load fp128, ptr %ptr2
199 %res = call fp128 @llvm.minimum.f128(fp128 %val1, fp128 %val2)
200 store fp128 %res, ptr %dst
204 ; Test a f128 constant compare/select resulting in minnum.
205 define void @f24(ptr %ptr, ptr %dst) {
207 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
208 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
209 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
210 ; CHECK: vst [[RES]], 0(%r3)
212 %val = load fp128, ptr %ptr
213 %cmp = fcmp olt fp128 %val, 0xL00000000000000000000000000000000
214 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
215 store fp128 %res, ptr %dst
219 ; Test a f128 constant compare/select resulting in minimum.
220 define void @f25(ptr %ptr, ptr %dst) {
222 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
223 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
224 ; CHECK: wfcxb [[REG1]], [[REG2]]
225 ; CHECK: vst [[RES]], 0(%r3)
227 %val = load fp128, ptr %ptr
228 %cmp = fcmp ult fp128 %val, 0xL00000000000000000000000000000000
229 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
230 store fp128 %res, ptr %dst