328 lines · plain
1; Verify that fp128 intrinsics only lower to `long double` calls (e.g. sinl) on2; platforms where 128 and `long double` have the same layout. Otherwise, lower3; 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; * Windows and MacOS (no f128 symbols, long double == f64)13 14; FIXME(#44744): arm32, x86-{32,64} musl targets, MacOS, and Windows don't have15; f128 long double. They should be passing with CHECK-F128 rather than16; CHECK-USELD.17 18; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}19; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}20; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-none | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}21; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=arm64-apple-macosx | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}22; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-none-eabi | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}23; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-unknown-linux-gnueabi | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}24; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}25; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}26; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}27; RUN: %if riscv-registered-target %{ llc < %s -mtriple=riscv32-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}28; RUN: %if systemz-registered-target %{ llc < %s -mtriple=s390x-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-S390X %}29; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}30; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}31; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}32; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}33;34; FIXME(#144006): Windows-MSVC should also be run but has a ldexp selection35; failure.36; %if x86-registered-target %{ llc < %s -mtriple=x86_64-pc-windows-msvc -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}37 38define fp128 @test_acos(fp128 %a) {39; CHECK-ALL-LABEL: test_acos:40; CHECK-F128: acosf12841; CHECK-USELD: acosl42; CHECK-S390X: acosl43start:44 %0 = tail call fp128 @llvm.acos.f128(fp128 %a)45 ret fp128 %046}47 48define fp128 @test_asin(fp128 %a) {49; CHECK-ALL-LABEL: test_asin:50; CHECK-F128: asinf12851; CHECK-USELD: asinl52; CHECK-S390X: asinl53start:54 %0 = tail call fp128 @llvm.asin.f128(fp128 %a)55 ret fp128 %056}57 58define fp128 @test_atan(fp128 %a) {59; CHECK-ALL-LABEL: test_atan:60; CHECK-F128: atanf12861; CHECK-USELD: atanl62; CHECK-S390X: atanl63start:64 %0 = tail call fp128 @llvm.atan.f128(fp128 %a)65 ret fp128 %066}67 68define fp128 @test_ceil(fp128 %a) {69; CHECK-ALL-LABEL: test_ceil:70; CHECK-F128: ceilf12871; CHECK-USELD: ceill72; CHECK-S390X: ceill73start:74 %0 = tail call fp128 @llvm.ceil.f128(fp128 %a)75 ret fp128 %076}77 78define fp128 @test_copysign(fp128 %a, fp128 %b) {79; copysign should always get lowered to assembly.80; CHECK-ALL-LABEL: test_copysign:81; CHECK-ALL-NOT: copysignf12882; CHECK-ALL-NOT: copysignl83start:84 %0 = tail call fp128 @llvm.copysign.f128(fp128 %a, fp128 %b)85 ret fp128 %086}87 88define fp128 @test_cos(fp128 %a) {89; CHECK-ALL-LABEL: test_cos:90; CHECK-F128: cosf12891; CHECK-USELD: cosl92; CHECK-S390X: cosl93start:94 %0 = tail call fp128 @llvm.cos.f128(fp128 %a)95 ret fp128 %096}97 98define fp128 @test_exp2(fp128 %a) {99; CHECK-ALL-LABEL: test_exp2:100; CHECK-F128: exp2f128101; CHECK-USELD: exp2l102; CHECK-S390X: exp2l103start:104 %0 = tail call fp128 @llvm.exp2.f128(fp128 %a)105 ret fp128 %0106}107 108 109define fp128 @test_exp(fp128 %a) {110; CHECK-ALL-LABEL: test_exp:111; CHECK-F128: expf128112; CHECK-USELD: expl113; CHECK-S390X: expl114start:115 %0 = tail call fp128 @llvm.exp.f128(fp128 %a)116 ret fp128 %0117}118 119define fp128 @test_fabs(fp128 %a) {120; fabs should always get lowered to assembly.121; CHECK-ALL-LABEL: test_fabs:122; CHECK-ALL-NOT: fabsf128123; CHECK-ALL-NOT: fabsl124start:125 %0 = tail call fp128 @llvm.fabs.f128(fp128 %a)126 ret fp128 %0127}128 129define fp128 @test_floor(fp128 %a) {130; CHECK-ALL-LABEL: test_floor:131; CHECK-F128: floorf128132; CHECK-USELD: floorl133; CHECK-S390X: floorl134start:135 %0 = tail call fp128 @llvm.floor.f128(fp128 %a)136 ret fp128 %0137}138 139define fp128 @test_fma(fp128 %a, fp128 %b, fp128 %c) {140; CHECK-ALL-LABEL: test_fma:141; CHECK-F128: fmaf128142; CHECK-USELD: fmal143; CHECK-S390X: fmal144start:145 %0 = tail call fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c)146 ret fp128 %0147}148 149define { fp128, i32 } @test_frexp(fp128 %a) {150; CHECK-ALL-LABEL: test_frexp:151; CHECK-F128: frexpf128152; CHECK-USELD: frexpl153; CHECK-S390X: frexpl154start:155 %0 = tail call { fp128, i32 } @llvm.frexp.f128(fp128 %a)156 ret { fp128, i32 } %0157}158 159define fp128 @test_ldexp(fp128 %a, i32 %b) {160; CHECK-ALL-LABEL: test_ldexp:161; CHECK-F128: ldexpf128162; CHECK-USELD: ldexpl163; CHECK-S390X: ldexpl164start:165 %0 = tail call fp128 @llvm.ldexp.f128(fp128 %a, i32 %b)166 ret fp128 %0167}168 169define i64 @test_llrint(fp128 %a) {170; CHECK-ALL-LABEL: test_llrint:171; CHECK-F128: llrintf128172; CHECK-USELD: llrintl173; CHECK-S390X: llrintl174start:175 %0 = tail call i64 @llvm.llrint.f128(fp128 %a)176 ret i64 %0177}178 179define i64 @test_llround(fp128 %a) {180; CHECK-ALL-LABEL: test_llround:181; CHECK-F128: llroundf128182; CHECK-USELD: llroundl183; CHECK-S390X: llroundl184start:185 %0 = tail call i64 @llvm.llround.i64.f128(fp128 %a)186 ret i64 %0187}188 189define fp128 @test_log10(fp128 %a) {190; CHECK-ALL-LABEL: test_log10:191; CHECK-F128: log10f128192; CHECK-USELD: log10l193; CHECK-S390X: log10l194start:195 %0 = tail call fp128 @llvm.log10.f128(fp128 %a)196 ret fp128 %0197}198 199define fp128 @test_log2(fp128 %a) {200; CHECK-ALL-LABEL: test_log2:201; CHECK-F128: log2f128202; CHECK-USELD: log2l203; CHECK-S390X: log2l204start:205 %0 = tail call fp128 @llvm.log2.f128(fp128 %a)206 ret fp128 %0207}208 209define fp128 @test_log(fp128 %a) {210; CHECK-ALL-LABEL: test_log:211; CHECK-F128: logf128212; CHECK-USELD: logl213; CHECK-S390X: logl214start:215 %0 = tail call fp128 @llvm.log.f128(fp128 %a)216 ret fp128 %0217}218 219define i64 @test_lrint(fp128 %a) {220; CHECK-ALL-LABEL: test_lrint:221; CHECK-F128: lrintf128222; CHECK-USELD: lrintl223; CHECK-S390X: lrintl224start:225 %0 = tail call i64 @llvm.lrint.f128(fp128 %a)226 ret i64 %0227}228 229define i64 @test_lround(fp128 %a) {230; CHECK-ALL-LABEL: test_lround:231; CHECK-F128: lroundf128232; CHECK-USELD: lroundl233; CHECK-S390X: lroundl234start:235 %0 = tail call i64 @llvm.lround.i64.f128(fp128 %a)236 ret i64 %0237}238 239define fp128 @test_nearbyint(fp128 %a) {240; CHECK-ALL-LABEL: test_nearbyint:241; CHECK-F128: nearbyintf128242; CHECK-USELD: nearbyintl243; CHECK-S390X: nearbyintl244start:245 %0 = tail call fp128 @llvm.nearbyint.f128(fp128 %a)246 ret fp128 %0247}248 249define fp128 @test_pow(fp128 %a, fp128 %b) {250; CHECK-ALL-LABEL: test_pow:251; CHECK-F128: powf128252; CHECK-USELD: powl253; CHECK-S390X: powl254start:255 %0 = tail call fp128 @llvm.pow.f128(fp128 %a, fp128 %b)256 ret fp128 %0257}258 259define fp128 @test_rint(fp128 %a) {260; CHECK-ALL-LABEL: test_rint:261; CHECK-F128: rintf128262; CHECK-USELD: rintl263; CHECK-S390X: fixbr {{%.*}}, 0, {{%.*}}264start:265 %0 = tail call fp128 @llvm.rint.f128(fp128 %a)266 ret fp128 %0267}268 269define fp128 @test_roundeven(fp128 %a) {270; CHECK-ALL-LABEL: test_roundeven:271; CHECK-F128: roundevenf128272; CHECK-USELD: roundevenl273; CHECK-S390X: roundevenl274start:275 %0 = tail call fp128 @llvm.roundeven.f128(fp128 %a)276 ret fp128 %0277}278 279define fp128 @test_round(fp128 %a) {280; CHECK-ALL-LABEL: test_round:281; CHECK-F128: roundf128282; CHECK-USELD: roundl283; CHECK-S390X: roundl284start:285 %0 = tail call fp128 @llvm.round.f128(fp128 %a)286 ret fp128 %0287}288 289define fp128 @test_sin(fp128 %a) {290; CHECK-ALL-LABEL: test_sin:291; CHECK-F128: sinf128292; CHECK-USELD: sinl293; CHECK-S390X: sinl294start:295 %0 = tail call fp128 @llvm.sin.f128(fp128 %a)296 ret fp128 %0297}298 299define fp128 @test_sqrt(fp128 %a) {300; CHECK-ALL-LABEL: test_sqrt:301; CHECK-F128: sqrtf128302; CHECK-USELD: sqrtl303; CHECK-S390X: sqxbr {{%.*}}, {{%.*}}304start:305 %0 = tail call fp128 @llvm.sqrt.f128(fp128 %a)306 ret fp128 %0307}308 309define fp128 @test_tan(fp128 %a) {310; CHECK-ALL-LABEL: test_tan:311; CHECK-F128: tanf128312; CHECK-USELD: tanl313; CHECK-S390X: tanl314start:315 %0 = tail call fp128 @llvm.tan.f128(fp128 %a)316 ret fp128 %0317}318 319define fp128 @test_trunc(fp128 %a) {320; CHECK-ALL-LABEL: test_trunc:321; CHECK-F128: truncf128322; CHECK-USELD: truncl323; CHECK-S390X: truncl324start:325 %0 = tail call fp128 @llvm.trunc.f128(fp128 %a)326 ret fp128 %0327}328