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 %f0, %f2
64 %cmp = fcmp ugt double %val, 0.0
65 %ret = select i1 %cmp, double %val, double 0.0
69 ; Test the v2f64 maxnum intrinsic.
70 define <2 x double> @f6(<2 x double> %dummy, <2 x double> %val1,
73 ; CHECK: vfmaxdb %v24, %v26, %v28, 4
75 %ret = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %val1, <2 x double> %val2)
79 ; Test the v2f64 maximum intrinsic.
80 define <2 x double> @f7(<2 x double> %dummy, <2 x double> %val1,
83 ; CHECK: vfmaxdb %v24, %v26, %v28, 1
85 %ret = call <2 x double> @llvm.maximum.v2f64(<2 x double> %val1, <2 x double> %val2)
89 ; Test the fmaxf library function.
90 define float @f11(float %dummy, float %val1, float %val2) {
92 ; CHECK: wfmaxsb %f0, %f2, %f4, 4
94 %ret = call float @fmaxf(float %val1, float %val2) readnone
98 ; Test the f32 maxnum intrinsic.
99 define float @f12(float %dummy, float %val1, float %val2) {
101 ; CHECK: wfmaxsb %f0, %f2, %f4, 4
103 %ret = call float @llvm.maxnum.f32(float %val1, float %val2)
107 ; Test the f32 maximum intrinsic.
108 define float @f13(float %dummy, float %val1, float %val2) {
110 ; CHECK: wfmaxsb %f0, %f2, %f4, 1
112 %ret = call float @llvm.maximum.f32(float %val1, float %val2)
116 ; Test a f32 constant compare/select resulting in maxnum.
117 define float @f14(float %dummy, float %val) {
119 ; CHECK: lzer [[REG:%f[0-9]+]]
120 ; CHECK: wfmaxsb %f0, %f2, [[REG]], 4
122 %cmp = fcmp ogt float %val, 0.0
123 %ret = select i1 %cmp, float %val, float 0.0
127 ; Test a f32 constant compare/select resulting in maximum.
128 define float @f15(float %dummy, float %val) {
130 ; CHECK: ltebr %f1, %f2
131 ; CHECK: ldr %f0, %f2
133 %cmp = fcmp ugt float %val, 0.0
134 %ret = select i1 %cmp, float %val, float 0.0
138 ; Test the v4f32 maxnum intrinsic.
139 define <4 x float> @f16(<4 x float> %dummy, <4 x float> %val1,
142 ; CHECK: vfmaxsb %v24, %v26, %v28, 4
144 %ret = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %val1, <4 x float> %val2)
148 ; Test the v4f32 maximum intrinsic.
149 define <4 x float> @f17(<4 x float> %dummy, <4 x float> %val1,
152 ; CHECK: vfmaxsb %v24, %v26, %v28, 1
154 %ret = call <4 x float> @llvm.maximum.v4f32(<4 x float> %val1, <4 x float> %val2)
158 ; Test the fmaxl 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: wfmaxxb [[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 @fmaxl(fp128 %val1, fp128 %val2) readnone
169 store fp128 %res, ptr %dst
173 ; Test the f128 maxnum 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: wfmaxxb [[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.maxnum.f128(fp128 %val1, fp128 %val2)
184 store fp128 %res, ptr %dst
188 ; Test the f128 maximum 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: wfmaxxb [[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.maximum.f128(fp128 %val1, fp128 %val2)
199 store fp128 %res, ptr %dst
203 ; Test a f128 constant compare/select resulting in maxnum.
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: wfmaxxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
209 ; CHECK: vst [[RES]], 0(%r3)
211 %val = load fp128, ptr %ptr
212 %cmp = fcmp ogt 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 maximum.
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 ugt fp128 %val, 0xL00000000000000000000000000000000
228 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
229 store fp128 %res, ptr %dst