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>) 8 9declare float @fminf(float, float) 10declare float @llvm.minnum.f32(float, float) 11declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) 12 13declare fp128 @fminl(fp128, fp128) 14declare fp128 @llvm.minnum.f128(fp128, fp128) 15 16; Test the fmin library function. 17define double @f1(double %dummy, double %val1, double %val2) { 18; CHECK-LABEL: f1: 19; CHECK: wfmindb %f0, %f2, %f4, 4 20; CHECK: br %r14 21 %ret = call double @fmin(double %val1, double %val2) readnone 22 ret double %ret 23} 24 25; Test the f64 minnum intrinsic. 26define double @f2(double %dummy, double %val1, double %val2) { 27; CHECK-LABEL: f2: 28; CHECK: wfmindb %f0, %f2, %f4, 4 29; CHECK: br %r14 30 %ret = call double @llvm.minnum.f64(double %val1, double %val2) 31 ret double %ret 32} 33 34; Test a f64 constant compare/select resulting in minnum. 35define double @f3(double %dummy, double %val) { 36; CHECK-LABEL: f3: 37; CHECK: lzdr [[REG:%f[0-9]+]] 38; CHECK: wfmindb %f0, %f2, [[REG]], 4 39; CHECK: br %r14 40 %cmp = fcmp olt double %val, 0.0 41 %ret = select i1 %cmp, double %val, double 0.0 42 ret double %ret 43} 44 45; Test a f64 constant compare/select resulting in minnan. 46define double @f4(double %dummy, double %val) { 47; CHECK-LABEL: f4: 48; CHECK: lzdr [[REG:%f[0-9]+]] 49; CHECK: wfmindb %f0, %f2, [[REG]], 1 50; CHECK: br %r14 51 %cmp = fcmp ult double %val, 0.0 52 %ret = select i1 %cmp, double %val, double 0.0 53 ret double %ret 54} 55 56; Test the v2f64 minnum intrinsic. 57define <2 x double> @f5(<2 x double> %dummy, <2 x double> %val1, 58 <2 x double> %val2) { 59; CHECK-LABEL: f5: 60; CHECK: vfmindb %v24, %v26, %v28, 4 61; CHECK: br %r14 62 %ret = call <2 x double> @llvm.minnum.v2f64(<2 x double> %val1, <2 x double> %val2) 63 ret <2 x double> %ret 64} 65 66; Test the fminf library function. 67define float @f11(float %dummy, float %val1, float %val2) { 68; CHECK-LABEL: f11: 69; CHECK: wfminsb %f0, %f2, %f4, 4 70; CHECK: br %r14 71 %ret = call float @fminf(float %val1, float %val2) readnone 72 ret float %ret 73} 74 75; Test the f32 minnum intrinsic. 76define float @f12(float %dummy, float %val1, float %val2) { 77; CHECK-LABEL: f12: 78; CHECK: wfminsb %f0, %f2, %f4, 4 79; CHECK: br %r14 80 %ret = call float @llvm.minnum.f32(float %val1, float %val2) 81 ret float %ret 82} 83 84; Test a f32 constant compare/select resulting in minnum. 85define float @f13(float %dummy, float %val) { 86; CHECK-LABEL: f13: 87; CHECK: lzer [[REG:%f[0-9]+]] 88; CHECK: wfminsb %f0, %f2, [[REG]], 4 89; CHECK: br %r14 90 %cmp = fcmp olt float %val, 0.0 91 %ret = select i1 %cmp, float %val, float 0.0 92 ret float %ret 93} 94 95; Test a f32 constant compare/select resulting in minnan. 96define float @f14(float %dummy, float %val) { 97; CHECK-LABEL: f14: 98; CHECK: lzer [[REG:%f[0-9]+]] 99; CHECK: wfminsb %f0, %f2, [[REG]], 1 100; CHECK: br %r14 101 %cmp = fcmp ult float %val, 0.0 102 %ret = select i1 %cmp, float %val, float 0.0 103 ret float %ret 104} 105 106; Test the v4f32 minnum intrinsic. 107define <4 x float> @f15(<4 x float> %dummy, <4 x float> %val1, 108 <4 x float> %val2) { 109; CHECK-LABEL: f15: 110; CHECK: vfminsb %v24, %v26, %v28, 4 111; CHECK: br %r14 112 %ret = call <4 x float> @llvm.minnum.v4f32(<4 x float> %val1, <4 x float> %val2) 113 ret <4 x float> %ret 114} 115 116; Test the fminl library function. 117define void @f21(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) { 118; CHECK-LABEL: f21: 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) 123; CHECK: br %r14 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 128 ret void 129} 130 131; Test the f128 minnum intrinsic. 132define void @f22(fp128 *%ptr1, fp128 *%ptr2, fp128 *%dst) { 133; CHECK-LABEL: f22: 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) 138; CHECK: br %r14 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 143 ret void 144} 145 146; Test a f128 constant compare/select resulting in minnum. 147define void @f23(fp128 *%ptr, fp128 *%dst) { 148; CHECK-LABEL: f23: 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) 153; CHECK: br %r14 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 158 ret void 159} 160 161; Test a f128 constant compare/select resulting in minnan. 162define void @f24(fp128 *%ptr, fp128 *%dst) { 163; CHECK-LABEL: f24: 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) 168; CHECK: br %r14 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 173 ret void 174} 175 176