|
| 1 | +; Verify that fp128 intrinsics only lower to `long double` calls (e.g. sinl) on |
| 2 | +; platforms where 128 and `long double` have the same layout.Otherwise, lower |
| 3 | +; to f128 versions (e.g. sinf128). |
| 4 | +; |
| 5 | +; Targets include: |
| 6 | +; * aarch64 (long double == f128, should use ld syms) |
| 7 | +; * arm (long double == f64, should use f128 syms) |
| 8 | +; * s390x (long double == f128, should use ld syms, some hardware support) |
| 9 | +; * x86, x64 (80-bit long double, should use ld syms) |
| 10 | +; * gnu (has f128 symbols on all platforms so we can use those) |
| 11 | +; * musl (no f128 symbols available) |
| 12 | + |
| 13 | +; FIXME: arm32 and x86-{32,64} musl targets don't have f128 long double, these |
| 14 | +; need to be updated. |
| 15 | + |
| 16 | +; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-none -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 17 | +; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 18 | +; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-musl -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 19 | +; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-none-eabi -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 20 | +; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-unknown-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 21 | +; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %} |
| 22 | +; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %} |
| 23 | +; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-musl -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %} |
| 24 | +; RUN: %if riscv-registered-target %{ llc < %s -mtriple=riscv32-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 25 | +; RUN: %if systemz-registered-target %{ llc < %s -mtriple=s390x-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-S390X %} |
| 26 | +; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %} |
| 27 | +; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-musl -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 28 | +; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %} |
| 29 | +; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-musl -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %} |
| 30 | + |
| 31 | +define fp128 @test_acos(fp128 %a) { |
| 32 | +; CHECK-ALL-LABEL: test_acos: |
| 33 | +; CHECK-F128: acosf128 |
| 34 | +; CHECK-USELD: acosl |
| 35 | +; CHECK-S390X: acosl |
| 36 | +start: |
| 37 | + %0 = tail call fp128 @llvm.acos.f128(fp128 %a) |
| 38 | + ret fp128 %0 |
| 39 | +} |
| 40 | + |
| 41 | +define fp128 @test_asin(fp128 %a) { |
| 42 | +; CHECK-ALL-LABEL: test_asin: |
| 43 | +; CHECK-F128: asinf128 |
| 44 | +; CHECK-USELD: asinl |
| 45 | +; CHECK-S390X: asinl |
| 46 | +start: |
| 47 | + %0 = tail call fp128 @llvm.asin.f128(fp128 %a) |
| 48 | + ret fp128 %0 |
| 49 | +} |
| 50 | + |
| 51 | +define fp128 @test_atan(fp128 %a) { |
| 52 | +; CHECK-ALL-LABEL: test_atan: |
| 53 | +; CHECK-F128: atanf128 |
| 54 | +; CHECK-USELD: atanl |
| 55 | +; CHECK-S390X: atanl |
| 56 | +start: |
| 57 | + %0 = tail call fp128 @llvm.atan.f128(fp128 %a) |
| 58 | + ret fp128 %0 |
| 59 | +} |
| 60 | + |
| 61 | +define fp128 @test_ceil(fp128 %a) { |
| 62 | +; CHECK-ALL-LABEL: test_ceil: |
| 63 | +; CHECK-F128: ceilf128 |
| 64 | +; CHECK-USELD: ceill |
| 65 | +; CHECK-S390X: ceill |
| 66 | +start: |
| 67 | + %0 = tail call fp128 @llvm.ceil.f128(fp128 %a) |
| 68 | + ret fp128 %0 |
| 69 | +} |
| 70 | + |
| 71 | +define fp128 @test_copysign(fp128 %a, fp128 %b) { |
| 72 | +; copysign should always get lowered to assembly. |
| 73 | +; CHECK-ALL-LABEL: test_copysign: |
| 74 | +; CHECK-ALL-NOT: copysignf128 |
| 75 | +; CHECK-ALL-NOT: copysignl |
| 76 | +start: |
| 77 | + %0 = tail call fp128 @llvm.copysign.f128(fp128 %a, fp128 %b) |
| 78 | + ret fp128 %0 |
| 79 | +} |
| 80 | + |
| 81 | +define fp128 @test_cos(fp128 %a) { |
| 82 | +; CHECK-ALL-LABEL: test_cos: |
| 83 | +; CHECK-F128: cosf128 |
| 84 | +; CHECK-USELD: cosl |
| 85 | +; CHECK-S390X: cosl |
| 86 | +start: |
| 87 | + %0 = tail call fp128 @llvm.cos.f128(fp128 %a) |
| 88 | + ret fp128 %0 |
| 89 | +} |
| 90 | + |
| 91 | +define fp128 @test_exp10(fp128 %a) { |
| 92 | +; CHECK-ALL-LABEL: test_exp10: |
| 93 | +; CHECK-F128: exp10f128 |
| 94 | +; CHECK-USELD: exp10l |
| 95 | +; CHECK-S390X: exp10l |
| 96 | +start: |
| 97 | + %0 = tail call fp128 @llvm.exp10.f128(fp128 %a) |
| 98 | + ret fp128 %0 |
| 99 | +} |
| 100 | + |
| 101 | +define fp128 @test_exp2(fp128 %a) { |
| 102 | +; CHECK-ALL-LABEL: test_exp2: |
| 103 | +; CHECK-F128: exp2f128 |
| 104 | +; CHECK-USELD: exp2l |
| 105 | +; CHECK-S390X: exp2l |
| 106 | +start: |
| 107 | + %0 = tail call fp128 @llvm.exp2.f128(fp128 %a) |
| 108 | + ret fp128 %0 |
| 109 | +} |
| 110 | + |
| 111 | + |
| 112 | +define fp128 @test_exp(fp128 %a) { |
| 113 | +; CHECK-ALL-LABEL: test_exp: |
| 114 | +; CHECK-F128: expf128 |
| 115 | +; CHECK-USELD: expl |
| 116 | +; CHECK-S390X: expl |
| 117 | +start: |
| 118 | + %0 = tail call fp128 @llvm.exp.f128(fp128 %a) |
| 119 | + ret fp128 %0 |
| 120 | +} |
| 121 | + |
| 122 | +define fp128 @test_fabs(fp128 %a) { |
| 123 | +; fabs should always get lowered to assembly. |
| 124 | +; CHECK-ALL-LABEL: test_fabs: |
| 125 | +; CHECK-ALL-NOT: fabsf128 |
| 126 | +; CHECK-ALL-NOT: fabsl |
| 127 | +start: |
| 128 | + %0 = tail call fp128 @llvm.fabs.f128(fp128 %a) |
| 129 | + ret fp128 %0 |
| 130 | +} |
| 131 | + |
| 132 | +define fp128 @test_floor(fp128 %a) { |
| 133 | +; CHECK-ALL-LABEL: test_floor: |
| 134 | +; CHECK-F128: floorf128 |
| 135 | +; CHECK-USELD: floorl |
| 136 | +; CHECK-S390X: floorl |
| 137 | +start: |
| 138 | + %0 = tail call fp128 @llvm.floor.f128(fp128 %a) |
| 139 | + ret fp128 %0 |
| 140 | +} |
| 141 | + |
| 142 | +define fp128 @test_fma(fp128 %a, fp128 %b, fp128 %c) { |
| 143 | +; CHECK-ALL-LABEL: test_fma: |
| 144 | +; CHECK-F128: fmaf128 |
| 145 | +; CHECK-USELD: fmal |
| 146 | +; CHECK-S390X: fmal |
| 147 | +start: |
| 148 | + %0 = tail call fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c) |
| 149 | + ret fp128 %0 |
| 150 | +} |
| 151 | + |
| 152 | +define { fp128, i32 } @test_frexp(fp128 %a) { |
| 153 | +; CHECK-ALL-LABEL: test_frexp: |
| 154 | +; CHECK-F128: frexpf128 |
| 155 | +; CHECK-USELD: frexpl |
| 156 | +; CHECK-S390X: frexpl |
| 157 | +start: |
| 158 | + %0 = tail call { fp128, i32 } @llvm.frexp.f128(fp128 %a) |
| 159 | + ret { fp128, i32 } %0 |
| 160 | +} |
| 161 | + |
| 162 | +define fp128 @test_ldexp(fp128 %a, i32 %b) { |
| 163 | +; CHECK-ALL-LABEL: test_ldexp: |
| 164 | +; CHECK-F128: ldexpf128 |
| 165 | +; CHECK-USELD: ldexpl |
| 166 | +; CHECK-S390X: ldexpl |
| 167 | +start: |
| 168 | + %0 = tail call fp128 @llvm.ldexp.f128(fp128 %a, i32 %b) |
| 169 | + ret fp128 %0 |
| 170 | +} |
| 171 | + |
| 172 | +define i64 @test_llrint(fp128 %a) { |
| 173 | +; CHECK-ALL-LABEL: test_llrint: |
| 174 | +; CHECK-F128: llrintf128 |
| 175 | +; CHECK-USELD: llrintl |
| 176 | +; CHECK-S390X: llrintl |
| 177 | +start: |
| 178 | + %0 = tail call i64 @llvm.llrint.f128(fp128 %a) |
| 179 | + ret i64 %0 |
| 180 | +} |
| 181 | + |
| 182 | +define i64 @test_llround(fp128 %a) { |
| 183 | +; CHECK-ALL-LABEL: test_llround: |
| 184 | +; CHECK-F128: llroundf128 |
| 185 | +; CHECK-USELD: llroundl |
| 186 | +; CHECK-S390X: llroundl |
| 187 | +start: |
| 188 | + %0 = tail call i64 @llvm.llround.i64.f128(fp128 %a) |
| 189 | + ret i64 %0 |
| 190 | +} |
| 191 | + |
| 192 | +define fp128 @test_log10(fp128 %a) { |
| 193 | +; CHECK-ALL-LABEL: test_log10: |
| 194 | +; CHECK-F128: log10f128 |
| 195 | +; CHECK-USELD: log10l |
| 196 | +; CHECK-S390X: log10l |
| 197 | +start: |
| 198 | + %0 = tail call fp128 @llvm.log10.f128(fp128 %a) |
| 199 | + ret fp128 %0 |
| 200 | +} |
| 201 | + |
| 202 | +define fp128 @test_log2(fp128 %a) { |
| 203 | +; CHECK-ALL-LABEL: test_log2: |
| 204 | +; CHECK-F128: log2f128 |
| 205 | +; CHECK-USELD: log2l |
| 206 | +; CHECK-S390X: log2l |
| 207 | +start: |
| 208 | + %0 = tail call fp128 @llvm.log2.f128(fp128 %a) |
| 209 | + ret fp128 %0 |
| 210 | +} |
| 211 | + |
| 212 | +define fp128 @test_log(fp128 %a) { |
| 213 | +; CHECK-ALL-LABEL: test_log: |
| 214 | +; CHECK-F128: logf128 |
| 215 | +; CHECK-USELD: logl |
| 216 | +; CHECK-S390X: logl |
| 217 | +start: |
| 218 | + %0 = tail call fp128 @llvm.log.f128(fp128 %a) |
| 219 | + ret fp128 %0 |
| 220 | +} |
| 221 | + |
| 222 | +define i64 @test_lrint(fp128 %a) { |
| 223 | +; CHECK-ALL-LABEL: test_lrint: |
| 224 | +; CHECK-F128: lrintf128 |
| 225 | +; CHECK-USELD: lrintl |
| 226 | +; CHECK-S390X: lrintl |
| 227 | +start: |
| 228 | + %0 = tail call i64 @llvm.lrint.f128(fp128 %a) |
| 229 | + ret i64 %0 |
| 230 | +} |
| 231 | + |
| 232 | +define i64 @test_lround(fp128 %a) { |
| 233 | +; CHECK-ALL-LABEL: test_lround: |
| 234 | +; CHECK-F128: lroundf128 |
| 235 | +; CHECK-USELD: lroundl |
| 236 | +; CHECK-S390X: lroundl |
| 237 | +start: |
| 238 | + %0 = tail call i64 @llvm.lround.i64.f128(fp128 %a) |
| 239 | + ret i64 %0 |
| 240 | +} |
| 241 | + |
| 242 | +define fp128 @test_nearbyint(fp128 %a) { |
| 243 | +; CHECK-ALL-LABEL: test_nearbyint: |
| 244 | +; CHECK-F128: nearbyintf128 |
| 245 | +; CHECK-USELD: nearbyintl |
| 246 | +; CHECK-S390X: nearbyintl |
| 247 | +start: |
| 248 | + %0 = tail call fp128 @llvm.nearbyint.f128(fp128 %a) |
| 249 | + ret fp128 %0 |
| 250 | +} |
| 251 | + |
| 252 | +define fp128 @test_pow(fp128 %a, fp128 %b) { |
| 253 | +; CHECK-ALL-LABEL: test_pow: |
| 254 | +; CHECK-F128: powf128 |
| 255 | +; CHECK-USELD: powl |
| 256 | +; CHECK-S390X: powl |
| 257 | +start: |
| 258 | + %0 = tail call fp128 @llvm.pow.f128(fp128 %a, fp128 %b) |
| 259 | + ret fp128 %0 |
| 260 | +} |
| 261 | + |
| 262 | +define fp128 @test_rint(fp128 %a) { |
| 263 | +; CHECK-ALL-LABEL: test_rint: |
| 264 | +; CHECK-F128: rintf128 |
| 265 | +; CHECK-USELD: rintl |
| 266 | +; CHECK-S390X: fixbr {{%.*}}, 0, {{%.*}} |
| 267 | +start: |
| 268 | + %0 = tail call fp128 @llvm.rint.f128(fp128 %a) |
| 269 | + ret fp128 %0 |
| 270 | +} |
| 271 | + |
| 272 | +define fp128 @test_roundeven(fp128 %a) { |
| 273 | +; CHECK-ALL-LABEL: test_roundeven: |
| 274 | +; CHECK-F128: roundevenf128 |
| 275 | +; CHECK-USELD: roundevenl |
| 276 | +; CHECK-S390X: roundevenl |
| 277 | +start: |
| 278 | + %0 = tail call fp128 @llvm.roundeven.f128(fp128 %a) |
| 279 | + ret fp128 %0 |
| 280 | +} |
| 281 | + |
| 282 | +define fp128 @test_round(fp128 %a) { |
| 283 | +; CHECK-ALL-LABEL: test_round: |
| 284 | +; CHECK-F128: roundf128 |
| 285 | +; CHECK-USELD: roundl |
| 286 | +; CHECK-S390X: roundl |
| 287 | +start: |
| 288 | + %0 = tail call fp128 @llvm.round.f128(fp128 %a) |
| 289 | + ret fp128 %0 |
| 290 | +} |
| 291 | + |
| 292 | +define fp128 @test_sin(fp128 %a) { |
| 293 | +; CHECK-ALL-LABEL: test_sin: |
| 294 | +; CHECK-F128: sinf128 |
| 295 | +; CHECK-USELD: sinl |
| 296 | +; CHECK-S390X: sinl |
| 297 | +start: |
| 298 | + %0 = tail call fp128 @llvm.sin.f128(fp128 %a) |
| 299 | + ret fp128 %0 |
| 300 | +} |
| 301 | + |
| 302 | +define fp128 @test_sqrt(fp128 %a) { |
| 303 | +; CHECK-ALL-LABEL: test_sqrt: |
| 304 | +; CHECK-F128: sqrtf128 |
| 305 | +; CHECK-USELD: sqrtl |
| 306 | +; CHECK-S390X: sqxbr {{%.*}}, {{%.*}} |
| 307 | +start: |
| 308 | + %0 = tail call fp128 @llvm.sqrt.f128(fp128 %a) |
| 309 | + ret fp128 %0 |
| 310 | +} |
| 311 | + |
| 312 | +define fp128 @test_tan(fp128 %a) { |
| 313 | +; CHECK-ALL-LABEL: test_tan: |
| 314 | +; CHECK-F128: tanf128 |
| 315 | +; CHECK-USELD: tanl |
| 316 | +; CHECK-S390X: tanl |
| 317 | +start: |
| 318 | + %0 = tail call fp128 @llvm.tan.f128(fp128 %a) |
| 319 | + ret fp128 %0 |
| 320 | +} |
| 321 | + |
| 322 | +define fp128 @test_trunc(fp128 %a) { |
| 323 | +; CHECK-ALL-LABEL: test_trunc: |
| 324 | +; CHECK-F128: truncf128 |
| 325 | +; CHECK-USELD: truncl |
| 326 | +; CHECK-S390X: truncl |
| 327 | +start: |
| 328 | + %0 = tail call fp128 @llvm.trunc.f128(fp128 %a) |
| 329 | + ret fp128 %0 |
| 330 | +} |
0 commit comments