1 ; Test rounding functions for z196 and above. 2 ; 3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 \ 4 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-SCALAR %s 5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 \ 6 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-VECTOR %s 7 8 ; Test rint for f32. 9 declare float @llvm.rint.f32(float %f) 10 define float @f1(float %f) { 11 ; CHECK-LABEL: f1: 12 ; CHECK: fiebr %f0, 0, %f0 13 ; CHECK: br %r14 14 %res = call float @llvm.rint.f32(float %f) 15 ret float %res 16 } 17 18 ; Test rint for f64. 19 declare double @llvm.rint.f64(double %f) 20 define double @f2(double %f) { 21 ; CHECK-LABEL: f2: 22 ; CHECK-SCALAR: fidbr %f0, 0, %f0 23 ; CHECK-VECTOR: fidbra %f0, 0, %f0, 0 24 ; CHECK: br %r14 25 %res = call double @llvm.rint.f64(double %f) 26 ret double %res 27 } 28 29 ; Test rint for f128. 30 declare fp128 @llvm.rint.f128(fp128 %f) 31 define void @f3(fp128 *%ptr) { 32 ; CHECK-LABEL: f3: 33 ; CHECK: fixbr %f0, 0, %f0 34 ; CHECK: br %r14 35 %src = load fp128 , fp128 *%ptr 36 %res = call fp128 @llvm.rint.f128(fp128 %src) 37 store fp128 %res, fp128 *%ptr 38 ret void 39 } 40 41 ; Test nearbyint for f32. 42 declare float @llvm.nearbyint.f32(float %f) 43 define float @f4(float %f) { 44 ; CHECK-LABEL: f4: 45 ; CHECK: fiebra %f0, 0, %f0, 4 46 ; CHECK: br %r14 47 %res = call float @llvm.nearbyint.f32(float %f) 48 ret float %res 49 } 50 51 ; Test nearbyint for f64. 52 declare double @llvm.nearbyint.f64(double %f) 53 define double @f5(double %f) { 54 ; CHECK-LABEL: f5: 55 ; CHECK: fidbra %f0, 0, %f0, 4 56 ; CHECK: br %r14 57 %res = call double @llvm.nearbyint.f64(double %f) 58 ret double %res 59 } 60 61 ; Test nearbyint for f128. 62 declare fp128 @llvm.nearbyint.f128(fp128 %f) 63 define void @f6(fp128 *%ptr) { 64 ; CHECK-LABEL: f6: 65 ; CHECK: fixbra %f0, 0, %f0, 4 66 ; CHECK: br %r14 67 %src = load fp128 , fp128 *%ptr 68 %res = call fp128 @llvm.nearbyint.f128(fp128 %src) 69 store fp128 %res, fp128 *%ptr 70 ret void 71 } 72 73 ; Test floor for f32. 74 declare float @llvm.floor.f32(float %f) 75 define float @f7(float %f) { 76 ; CHECK-LABEL: f7: 77 ; CHECK: fiebra %f0, 7, %f0, 4 78 ; CHECK: br %r14 79 %res = call float @llvm.floor.f32(float %f) 80 ret float %res 81 } 82 83 ; Test floor for f64. 84 declare double @llvm.floor.f64(double %f) 85 define double @f8(double %f) { 86 ; CHECK-LABEL: f8: 87 ; CHECK: fidbra %f0, 7, %f0, 4 88 ; CHECK: br %r14 89 %res = call double @llvm.floor.f64(double %f) 90 ret double %res 91 } 92 93 ; Test floor for f128. 94 declare fp128 @llvm.floor.f128(fp128 %f) 95 define void @f9(fp128 *%ptr) { 96 ; CHECK-LABEL: f9: 97 ; CHECK: fixbra %f0, 7, %f0, 4 98 ; CHECK: br %r14 99 %src = load fp128 , fp128 *%ptr 100 %res = call fp128 @llvm.floor.f128(fp128 %src) 101 store fp128 %res, fp128 *%ptr 102 ret void 103 } 104 105 ; Test ceil for f32. 106 declare float @llvm.ceil.f32(float %f) 107 define float @f10(float %f) { 108 ; CHECK-LABEL: f10: 109 ; CHECK: fiebra %f0, 6, %f0, 4 110 ; CHECK: br %r14 111 %res = call float @llvm.ceil.f32(float %f) 112 ret float %res 113 } 114 115 ; Test ceil for f64. 116 declare double @llvm.ceil.f64(double %f) 117 define double @f11(double %f) { 118 ; CHECK-LABEL: f11: 119 ; CHECK: fidbra %f0, 6, %f0, 4 120 ; CHECK: br %r14 121 %res = call double @llvm.ceil.f64(double %f) 122 ret double %res 123 } 124 125 ; Test ceil for f128. 126 declare fp128 @llvm.ceil.f128(fp128 %f) 127 define void @f12(fp128 *%ptr) { 128 ; CHECK-LABEL: f12: 129 ; CHECK: fixbra %f0, 6, %f0, 4 130 ; CHECK: br %r14 131 %src = load fp128 , fp128 *%ptr 132 %res = call fp128 @llvm.ceil.f128(fp128 %src) 133 store fp128 %res, fp128 *%ptr 134 ret void 135 } 136 137 ; Test trunc for f32. 138 declare float @llvm.trunc.f32(float %f) 139 define float @f13(float %f) { 140 ; CHECK-LABEL: f13: 141 ; CHECK: fiebra %f0, 5, %f0, 4 142 ; CHECK: br %r14 143 %res = call float @llvm.trunc.f32(float %f) 144 ret float %res 145 } 146 147 ; Test trunc for f64. 148 declare double @llvm.trunc.f64(double %f) 149 define double @f14(double %f) { 150 ; CHECK-LABEL: f14: 151 ; CHECK: fidbra %f0, 5, %f0, 4 152 ; CHECK: br %r14 153 %res = call double @llvm.trunc.f64(double %f) 154 ret double %res 155 } 156 157 ; Test trunc for f128. 158 declare fp128 @llvm.trunc.f128(fp128 %f) 159 define void @f15(fp128 *%ptr) { 160 ; CHECK-LABEL: f15: 161 ; CHECK: fixbra %f0, 5, %f0, 4 162 ; CHECK: br %r14 163 %src = load fp128 , fp128 *%ptr 164 %res = call fp128 @llvm.trunc.f128(fp128 %src) 165 store fp128 %res, fp128 *%ptr 166 ret void 167 } 168 169 ; Test round for f32. 170 declare float @llvm.round.f32(float %f) 171 define float @f16(float %f) { 172 ; CHECK-LABEL: f16: 173 ; CHECK: fiebra %f0, 1, %f0, 4 174 ; CHECK: br %r14 175 %res = call float @llvm.round.f32(float %f) 176 ret float %res 177 } 178 179 ; Test round for f64. 180 declare double @llvm.round.f64(double %f) 181 define double @f17(double %f) { 182 ; CHECK-LABEL: f17: 183 ; CHECK: fidbra %f0, 1, %f0, 4 184 ; CHECK: br %r14 185 %res = call double @llvm.round.f64(double %f) 186 ret double %res 187 } 188 189 ; Test round for f128. 190 declare fp128 @llvm.round.f128(fp128 %f) 191 define void @f18(fp128 *%ptr) { 192 ; CHECK-LABEL: f18: 193 ; CHECK: fixbra %f0, 1, %f0, 4 194 ; CHECK: br %r14 195 %src = load fp128 , fp128 *%ptr 196 %res = call fp128 @llvm.round.f128(fp128 %src) 197 store fp128 %res, fp128 *%ptr 198 ret void 199 } 200