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>)
9 declare float @fminf(float, float)
10 declare float @llvm.minnum.f32(float, float)
11 declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>)
13 declare fp128 @fminl(fp128, fp128)
14 declare fp128 @llvm.minnum.f128(fp128, fp128)
16 ; Test the fmin library function.
17 define double @f1(double %dummy, double %val1, double %val2) {
19 ; CHECK: wfmindb %f0, %f2, %f4, 4
21 %ret = call double @fmin(double %val1, double %val2) readnone
25 ; Test the f64 minnum intrinsic.
26 define double @f2(double %dummy, double %val1, double %val2) {
28 ; CHECK: wfmindb %f0, %f2, %f4, 4
30 %ret = call double @llvm.minnum.f64(double %val1, double %val2)
34 ; Test a f64 constant compare/select resulting in minnum.
35 define double @f3(double %dummy, double %val) {
37 ; CHECK: lzdr [[REG:%f[0-9]+]]
38 ; CHECK: wfmindb %f0, %f2, [[REG]], 4
40 %cmp = fcmp olt double %val, 0.0
41 %ret = select i1 %cmp, double %val, double 0.0
45 ; Test a f64 constant compare/select resulting in minimum.
46 define double @f4(double %dummy, double %val) {
48 ; CHECK: lzdr [[REG:%f[0-9]+]]
49 ; CHECK: wfmindb %f0, %f2, [[REG]], 1
51 %cmp = fcmp ult double %val, 0.0
52 %ret = select i1 %cmp, double %val, double 0.0
56 ; Test the v2f64 minnum intrinsic.
57 define <2 x double> @f5(<2 x double> %dummy, <2 x double> %val1,
60 ; CHECK: vfmindb %v24, %v26, %v28, 4
62 %ret = call <2 x double> @llvm.minnum.v2f64(<2 x double> %val1, <2 x double> %val2)
66 ; Test the fminf library function.
67 define float @f11(float %dummy, float %val1, float %val2) {
69 ; CHECK: wfminsb %f0, %f2, %f4, 4
71 %ret = call float @fminf(float %val1, float %val2) readnone
75 ; Test the f32 minnum intrinsic.
76 define float @f12(float %dummy, float %val1, float %val2) {
78 ; CHECK: wfminsb %f0, %f2, %f4, 4
80 %ret = call float @llvm.minnum.f32(float %val1, float %val2)
84 ; Test a f32 constant compare/select resulting in minnum.
85 define float @f13(float %dummy, float %val) {
87 ; CHECK: lzer [[REG:%f[0-9]+]]
88 ; CHECK: wfminsb %f0, %f2, [[REG]], 4
90 %cmp = fcmp olt float %val, 0.0
91 %ret = select i1 %cmp, float %val, float 0.0
95 ; Test a f32 constant compare/select resulting in minimum.
96 define float @f14(float %dummy, float %val) {
98 ; CHECK: lzer [[REG:%f[0-9]+]]
99 ; CHECK: wfminsb %f0, %f2, [[REG]], 1
101 %cmp = fcmp ult float %val, 0.0
102 %ret = select i1 %cmp, float %val, float 0.0
106 ; Test the v4f32 minnum intrinsic.
107 define <4 x float> @f15(<4 x float> %dummy, <4 x float> %val1,
110 ; CHECK: vfminsb %v24, %v26, %v28, 4
112 %ret = call <4 x float> @llvm.minnum.v4f32(<4 x float> %val1, <4 x float> %val2)
116 ; Test the fminl library function.
117 define void @f21(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) {
119 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
120 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
121 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
122 ; CHECK: vst [[RES]], 0(%r4)
124 %val1 = load fp128, fp128* %ptr1
125 %val2 = load fp128, fp128* %ptr2
126 %res = call fp128 @fminl(fp128 %val1, fp128 %val2) readnone
127 store fp128 %res, fp128* %dst
131 ; Test the f128 minnum intrinsic.
132 define void @f22(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) {
134 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
135 ; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
136 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
137 ; CHECK: vst [[RES]], 0(%r4)
139 %val1 = load fp128, fp128* %ptr1
140 %val2 = load fp128, fp128* %ptr2
141 %res = call fp128 @llvm.minnum.f128(fp128 %val1, fp128 %val2)
142 store fp128 %res, fp128* %dst
146 ; Test a f128 constant compare/select resulting in minnum.
147 define void @f23(fp128 *%ptr, fp128 *%dst) {
149 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
150 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
151 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 4
152 ; CHECK: vst [[RES]], 0(%r3)
154 %val = load fp128, fp128* %ptr
155 %cmp = fcmp olt fp128 %val, 0xL00000000000000000000000000000000
156 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
157 store fp128 %res, fp128* %dst
161 ; Test a f128 constant compare/select resulting in minimum.
162 define void @f24(fp128 *%ptr, fp128 *%dst) {
164 ; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
165 ; CHECK-DAG: vzero [[REG2:%v[0-9]+]]
166 ; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 1
167 ; CHECK: vst [[RES]], 0(%r3)
169 %val = load fp128, fp128* %ptr
170 %cmp = fcmp ult fp128 %val, 0xL00000000000000000000000000000000
171 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000
172 store fp128 %res, fp128* %dst