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 %f0, %f2
64 %cmp = fcmp ult double %val, 0.0
65 %ret = select i1 %cmp, double %val, double 0.0
69 ; Test the v2f64 minnum intrinsic.
70 define <2 x double> @f6(<2 x double> %dummy, <2 x double> %val1,
73 ; CHECK: vfmindb %v24, %v26, %v28, 4
75 %ret = call <2 x double> @llvm.minnum.v2f64(<2 x double> %val1, <2 x double> %val2)
79 ; Test the v2f64 minimum intrinsic.
80 define <2 x double> @f7(<2 x double> %dummy, <2 x double> %val1,
83 ; CHECK: vfmindb %v24, %v26, %v28, 1
85 %ret = call <2 x double> @llvm.minimum.v2f64(<2 x double> %val1, <2 x double> %val2)
89 ; Test the fminf library function.
90 define float @f11(float %dummy, float %val1, float %val2) {
92 ; CHECK: wfminsb %f0, %f2, %f4, 4
94 %ret = call float @fminf(float %val1, float %val2) readnone
98 ; Test the f32 minnum intrinsic.
99 define float @f12(float %dummy, float %val1, float %val2) {
101 ; CHECK: wfminsb %f0, %f2, %f4, 4
103 %ret = call float @llvm.minnum.f32(float %val1, float %val2)
107 ; Test the f32 minimum intrinsic.
108 define float @f13(float %dummy, float %val1, float %val2) {
110 ; CHECK: wfminsb %f0, %f2, %f4, 1
112 %ret = call float @llvm.minimum.f32(float %val1, float %val2)
116 ; Test a f32 constant compare/select resulting in minnum.
117 define float @f14(float %dummy, float %val) {
119 ; CHECK: lzer [[REG:%f[0-9]+]]
120 ; CHECK: wfminsb %f0, %f2, [[REG]], 4
122 %cmp = fcmp olt float %val, 0.0
123 %ret = select i1 %cmp, float %val, float 0.0
127 ; Test a f32 constant compare/select resulting in minimum.
128 define float @f15(float %dummy, float %val) {
130 ; CHECK: ltebr %f1, %f2
131 ; CHECK: ldr %f0, %f2
133 %cmp = fcmp ult float %val, 0.0
134 %ret = select i1 %cmp, float %val, float 0.0
138 ; Test the v4f32 minnum intrinsic.
139 define <4 x float> @f16(<4 x float> %dummy, <4 x float> %val1,
142 ; CHECK: vfminsb %v24, %v26, %v28, 4
144 %ret = call <4 x float> @llvm.minnum.v4f32(<4 x float> %val1, <4 x float> %val2)
148 ; Test the v4f32 minimum intrinsic.
149 define <4 x float> @f17(<4 x float> %dummy, <4 x float> %val1,
152 ; CHECK: vfminsb %v24, %v26, %v28, 1
154 %ret = call <4 x float> @llvm.minimum.v4f32(<4 x float> %val1, <4 x float> %val2)
158 ; Test the fminl library function.
159 define void @f21(ptr %ptr1, ptr %ptr2, ptr %dst) {
161 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
162 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
163 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
164 ; CHECK: vst [[RES]], 0(%r4)
166 %val1 = load fp128, ptr %ptr1
167 %val2 = load fp128, ptr %ptr2
168 %res = call fp128 @fminl(fp128 %val1, fp128 %val2) readnone
169 store fp128 %res, ptr %dst
173 ; Test the f128 minnum intrinsic.
174 define void @f22(ptr %ptr1, ptr %ptr2, ptr %dst) {
176 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
177 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
178 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
179 ; CHECK: vst [[RES]], 0(%r4)
181 %val1 = load fp128, ptr %ptr1
182 %val2 = load fp128, ptr %ptr2
183 %res = call fp128 @llvm.minnum.f128(fp128 %val1, fp128 %val2)
184 store fp128 %res, ptr %dst
188 ; Test the f128 minimum intrinsic.
189 define void @f23(ptr %ptr1, ptr %ptr2, ptr %dst) {
191 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
192 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
193 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 1
194 ; CHECK: vst [[RES]], 0(%r4)
196 %val1 = load fp128, ptr %ptr1
197 %val2 = load fp128, ptr %ptr2
198 %res = call fp128 @llvm.minimum.f128(fp128 %val1, fp128 %val2)
199 store fp128 %res, ptr %dst
203 ; Test a f128 constant compare/select resulting in minnum.
204 define void @f24(ptr %ptr, ptr %dst) {
206 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
207 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
208 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
209 ; CHECK: vst [[RES]], 0(%r3)
211 %val = load fp128, ptr %ptr
212 %cmp = fcmp olt fp128 %val, 0xL00000000000000000000000000000000
213 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
214 store fp128 %res, ptr %dst
218 ; Test a f128 constant compare/select resulting in minimum.
219 define void @f25(ptr %ptr, ptr %dst) {
221 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
222 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
223 ; CHECK: wfcxb [[REG1]], [[REG2]]
224 ; CHECK: vst [[RES]], 0(%r3)
226 %val = load fp128, ptr %ptr
227 %cmp = fcmp ult fp128 %val, 0xL00000000000000000000000000000000
228 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
229 store fp128 %res, ptr %dst