1 ; Test vector maximum on z14.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
5 declare double @fmax(double, double)
6 declare double @llvm.maxnum.f64(double, double)
7 declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
8 declare double @llvm.maximum.f64(double, double)
9 declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>)
11 declare float @fmaxf(float, float)
12 declare float @llvm.maxnum.f32(float, float)
13 declare <4 x float> @llvm.maxnum.v4f32(<4 x float>, <4 x float>)
14 declare float @llvm.maximum.f32(float, float)
15 declare <4 x float> @llvm.maximum.v4f32(<4 x float>, <4 x float>)
17 declare fp128 @fmaxl(fp128, fp128)
18 declare fp128 @llvm.maxnum.f128(fp128, fp128)
19 declare fp128 @llvm.maximum.f128(fp128, fp128)
21 ; Test the fmax library function.
22 define double @f1(double %dummy, double %val1, double %val2) {
24 ; CHECK: wfmaxdb %f0, %f2, %f4, 4
26 %ret = call double @fmax(double %val1, double %val2) readnone
30 ; Test the f64 maxnum intrinsic.
31 define double @f2(double %dummy, double %val1, double %val2) {
33 ; CHECK: wfmaxdb %f0, %f2, %f4, 4
35 %ret = call double @llvm.maxnum.f64(double %val1, double %val2)
39 ; Test the f64 maximum intrinsic.
40 define double @f3(double %dummy, double %val1, double %val2) {
42 ; CHECK: wfmaxdb %f0, %f2, %f4, 1
44 %ret = call double @llvm.maximum.f64(double %val1, double %val2)
48 ; Test a f64 constant compare/select resulting in maxnum.
49 define double @f4(double %dummy, double %val) {
51 ; CHECK: lzdr [[REG:%f[0-9]+]]
52 ; CHECK: wfmaxdb %f0, %f2, [[REG]], 4
54 %cmp = fcmp ogt double %val, 0.0
55 %ret = select i1 %cmp, double %val, double 0.0
59 ; Test a f64 constant compare/select resulting in maximum.
60 define double @f5(double %dummy, double %val) {
62 ; CHECK: ltdbr %f1, %f2
63 ; CHECK-NEXT: ldr %f0, %f2
65 %cmp = fcmp ugt double %val, 0.0
66 %ret = select i1 %cmp, double %val, double 0.0
70 ; Test the v2f64 maxnum intrinsic.
71 define <2 x double> @f6(<2 x double> %dummy, <2 x double> %val1,
74 ; CHECK: vfmaxdb %v24, %v26, %v28, 4
76 %ret = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %val1, <2 x double> %val2)
80 ; Test the v2f64 maximum intrinsic.
81 define <2 x double> @f7(<2 x double> %dummy, <2 x double> %val1,
84 ; CHECK: vfmaxdb %v24, %v26, %v28, 1
86 %ret = call <2 x double> @llvm.maximum.v2f64(<2 x double> %val1, <2 x double> %val2)
90 ; Test the fmaxf library function.
91 define float @f11(float %dummy, float %val1, float %val2) {
93 ; CHECK: wfmaxsb %f0, %f2, %f4, 4
95 %ret = call float @fmaxf(float %val1, float %val2) readnone
99 ; Test the f32 maxnum intrinsic.
100 define float @f12(float %dummy, float %val1, float %val2) {
102 ; CHECK: wfmaxsb %f0, %f2, %f4, 4
104 %ret = call float @llvm.maxnum.f32(float %val1, float %val2)
108 ; Test the f32 maximum intrinsic.
109 define float @f13(float %dummy, float %val1, float %val2) {
111 ; CHECK: wfmaxsb %f0, %f2, %f4, 1
113 %ret = call float @llvm.maximum.f32(float %val1, float %val2)
117 ; Test a f32 constant compare/select resulting in maxnum.
118 define float @f14(float %dummy, float %val) {
120 ; CHECK: lzer [[REG:%f[0-9]+]]
121 ; CHECK: wfmaxsb %f0, %f2, [[REG]], 4
123 %cmp = fcmp ogt float %val, 0.0
124 %ret = select i1 %cmp, float %val, float 0.0
128 ; Test a f32 constant compare/select resulting in maximum.
129 define float @f15(float %dummy, float %val) {
131 ; CHECK: ltebr %f1, %f2
132 ; CHECK: ldr %f0, %f2
134 %cmp = fcmp ugt float %val, 0.0
135 %ret = select i1 %cmp, float %val, float 0.0
139 ; Test the v4f32 maxnum intrinsic.
140 define <4 x float> @f16(<4 x float> %dummy, <4 x float> %val1,
143 ; CHECK: vfmaxsb %v24, %v26, %v28, 4
145 %ret = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %val1, <4 x float> %val2)
149 ; Test the v4f32 maximum intrinsic.
150 define <4 x float> @f17(<4 x float> %dummy, <4 x float> %val1,
153 ; CHECK: vfmaxsb %v24, %v26, %v28, 1
155 %ret = call <4 x float> @llvm.maximum.v4f32(<4 x float> %val1, <4 x float> %val2)
159 ; Test the fmaxl 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: wfmaxxb [[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 @fmaxl(fp128 %val1, fp128 %val2) readnone
170 store fp128 %res, ptr %dst
174 ; Test the f128 maxnum 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: wfmaxxb [[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.maxnum.f128(fp128 %val1, fp128 %val2)
185 store fp128 %res, ptr %dst
189 ; Test the f128 maximum 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: wfmaxxb [[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.maximum.f128(fp128 %val1, fp128 %val2)
200 store fp128 %res, ptr %dst
204 ; Test a f128 constant compare/select resulting in maxnum.
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: wfmaxxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
210 ; CHECK: vst [[RES]], 0(%r3)
212 %val = load fp128, ptr %ptr
213 %cmp = fcmp ogt 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 maximum.
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 ugt fp128 %val, 0xL00000000000000000000000000000000
229 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
230 store fp128 %res, ptr %dst