1; Test vector minimum on z14. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s 4 5declare double @fmin(double, double) 6declare double @llvm.minnum.f64(double, double) 7declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>) 8declare double @llvm.minimum.f64(double, double) 9declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>) 10 11declare float @fminf(float, float) 12declare float @llvm.minnum.f32(float, float) 13declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) 14declare float @llvm.minimum.f32(float, float) 15declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>) 16 17declare fp128 @fminl(fp128, fp128) 18declare fp128 @llvm.minnum.f128(fp128, fp128) 19declare fp128 @llvm.minimum.f128(fp128, fp128) 20 21; Test the fmin library function. 22define double @f1(double %dummy, double %val1, double %val2) { 23; CHECK-LABEL: f1: 24; CHECK: wfmindb %f0, %f2, %f4, 4 25; CHECK: br %r14 26 %ret = call double @fmin(double %val1, double %val2) readnone 27 ret double %ret 28} 29 30; Test the f64 minnum intrinsic. 31define double @f2(double %dummy, double %val1, double %val2) { 32; CHECK-LABEL: f2: 33; CHECK: wfmindb %f0, %f2, %f4, 4 34; CHECK: br %r14 35 %ret = call double @llvm.minnum.f64(double %val1, double %val2) 36 ret double %ret 37} 38 39; Test the f64 minimum intrinsic. 40define double @f3(double %dummy, double %val1, double %val2) { 41; CHECK-LABEL: f3: 42; CHECK: wfmindb %f0, %f2, %f4, 1 43; CHECK: br %r14 44 %ret = call double @llvm.minimum.f64(double %val1, double %val2) 45 ret double %ret 46} 47 48; Test a f64 constant compare/select resulting in minnum. 49define double @f4(double %dummy, double %val) { 50; CHECK-LABEL: f4: 51; CHECK: lzdr [[REG:%f[0-9]+]] 52; CHECK: wfmindb %f0, %f2, [[REG]], 4 53; CHECK: br %r14 54 %cmp = fcmp olt double %val, 0.0 55 %ret = select i1 %cmp, double %val, double 0.0 56 ret double %ret 57} 58 59; Test a f64 constant compare/select resulting in minimum. 60define double @f5(double %dummy, double %val) { 61; CHECK-LABEL: f5: 62; CHECK: lzdr [[REG:%f[0-9]+]] 63; CHECK: wfmindb %f0, %f2, [[REG]], 1 64; CHECK: br %r14 65 %cmp = fcmp ult double %val, 0.0 66 %ret = select i1 %cmp, double %val, double 0.0 67 ret double %ret 68} 69 70; Test the v2f64 minnum intrinsic. 71define <2 x double> @f6(<2 x double> %dummy, <2 x double> %val1, 72 <2 x double> %val2) { 73; CHECK-LABEL: f6: 74; CHECK: vfmindb %v24, %v26, %v28, 4 75; CHECK: br %r14 76 %ret = call <2 x double> @llvm.minnum.v2f64(<2 x double> %val1, <2 x double> %val2) 77 ret <2 x double> %ret 78} 79 80; Test the v2f64 minimum intrinsic. 81define <2 x double> @f7(<2 x double> %dummy, <2 x double> %val1, 82 <2 x double> %val2) { 83; CHECK-LABEL: f7: 84; CHECK: vfmindb %v24, %v26, %v28, 1 85; CHECK: br %r14 86 %ret = call <2 x double> @llvm.minimum.v2f64(<2 x double> %val1, <2 x double> %val2) 87 ret <2 x double> %ret 88} 89 90; Test the fminf library function. 91define float @f11(float %dummy, float %val1, float %val2) { 92; CHECK-LABEL: f11: 93; CHECK: wfminsb %f0, %f2, %f4, 4 94; CHECK: br %r14 95 %ret = call float @fminf(float %val1, float %val2) readnone 96 ret float %ret 97} 98 99; Test the f32 minnum intrinsic. 100define float @f12(float %dummy, float %val1, float %val2) { 101; CHECK-LABEL: f12: 102; CHECK: wfminsb %f0, %f2, %f4, 4 103; CHECK: br %r14 104 %ret = call float @llvm.minnum.f32(float %val1, float %val2) 105 ret float %ret 106} 107 108; Test the f32 minimum intrinsic. 109define float @f13(float %dummy, float %val1, float %val2) { 110; CHECK-LABEL: f13: 111; CHECK: wfminsb %f0, %f2, %f4, 1 112; CHECK: br %r14 113 %ret = call float @llvm.minimum.f32(float %val1, float %val2) 114 ret float %ret 115} 116 117; Test a f32 constant compare/select resulting in minnum. 118define float @f14(float %dummy, float %val) { 119; CHECK-LABEL: f14: 120; CHECK: lzer [[REG:%f[0-9]+]] 121; CHECK: wfminsb %f0, %f2, [[REG]], 4 122; CHECK: br %r14 123 %cmp = fcmp olt float %val, 0.0 124 %ret = select i1 %cmp, float %val, float 0.0 125 ret float %ret 126} 127 128; Test a f32 constant compare/select resulting in minimum. 129define float @f15(float %dummy, float %val) { 130; CHECK-LABEL: f15: 131; CHECK: lzer [[REG:%f[0-9]+]] 132; CHECK: wfminsb %f0, %f2, [[REG]], 1 133; CHECK: br %r14 134 %cmp = fcmp ult float %val, 0.0 135 %ret = select i1 %cmp, float %val, float 0.0 136 ret float %ret 137} 138 139; Test the v4f32 minnum intrinsic. 140define <4 x float> @f16(<4 x float> %dummy, <4 x float> %val1, 141 <4 x float> %val2) { 142; CHECK-LABEL: f16: 143; CHECK: vfminsb %v24, %v26, %v28, 4 144; CHECK: br %r14 145 %ret = call <4 x float> @llvm.minnum.v4f32(<4 x float> %val1, <4 x float> %val2) 146 ret <4 x float> %ret 147} 148 149; Test the v4f32 minimum intrinsic. 150define <4 x float> @f17(<4 x float> %dummy, <4 x float> %val1, 151 <4 x float> %val2) { 152; CHECK-LABEL: f17: 153; CHECK: vfminsb %v24, %v26, %v28, 1 154; CHECK: br %r14 155 %ret = call <4 x float> @llvm.minimum.v4f32(<4 x float> %val1, <4 x float> %val2) 156 ret <4 x float> %ret 157} 158 159; Test the fminl library function. 160define void @f21(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) { 161; CHECK-LABEL: f21: 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) 166; CHECK: br %r14 167 %val1 = load fp128, fp128* %ptr1 168 %val2 = load fp128, fp128* %ptr2 169 %res = call fp128 @fminl(fp128 %val1, fp128 %val2) readnone 170 store fp128 %res, fp128* %dst 171 ret void 172} 173 174; Test the f128 minnum intrinsic. 175define void @f22(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) { 176; CHECK-LABEL: f22: 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) 181; CHECK: br %r14 182 %val1 = load fp128, fp128* %ptr1 183 %val2 = load fp128, fp128* %ptr2 184 %res = call fp128 @llvm.minnum.f128(fp128 %val1, fp128 %val2) 185 store fp128 %res, fp128* %dst 186 ret void 187} 188 189; Test the f128 minimum intrinsic. 190define void @f23(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) { 191; CHECK-LABEL: f23: 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) 196; CHECK: br %r14 197 %val1 = load fp128, fp128* %ptr1 198 %val2 = load fp128, fp128* %ptr2 199 %res = call fp128 @llvm.minimum.f128(fp128 %val1, fp128 %val2) 200 store fp128 %res, fp128* %dst 201 ret void 202} 203 204; Test a f128 constant compare/select resulting in minnum. 205define void @f24(fp128 *%ptr, fp128 *%dst) { 206; CHECK-LABEL: f24: 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) 211; CHECK: br %r14 212 %val = load fp128, fp128* %ptr 213 %cmp = fcmp olt fp128 %val, 0xL00000000000000000000000000000000 214 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000 215 store fp128 %res, fp128* %dst 216 ret void 217} 218 219; Test a f128 constant compare/select resulting in minimum. 220define void @f25(fp128 *%ptr, fp128 *%dst) { 221; CHECK-LABEL: f25: 222; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2) 223; CHECK-DAG: vzero [[REG2:%v[0-9]+]] 224; CHECK: wfminxb [[RES:%v[0-9]+]], [[REG1]], [[REG2]], 1 225; CHECK: vst [[RES]], 0(%r3) 226; CHECK: br %r14 227 %val = load fp128, fp128* %ptr 228 %cmp = fcmp ult fp128 %val, 0xL00000000000000000000000000000000 229 %res = select i1 %cmp, fp128 %val, fp128 0xL00000000000000000000000000000000 230 store fp128 %res, fp128* %dst 231 ret void 232} 233 234