1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
3 ; Test a subset of compiler-rt/libm libcalls expected to be emitted by the wasm backend
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 declare fp128 @llvm.sqrt.f128(fp128)
9 declare fp128 @llvm.floor.f128(fp128)
10 declare fp128 @llvm.trunc.f128(fp128)
11 declare fp128 @llvm.nearbyint.f128(fp128)
12 declare fp128 @llvm.pow.f128(fp128, fp128)
14 declare double @llvm.cos.f64(double)
15 declare double @llvm.log10.f64(double)
16 declare double @llvm.pow.f64(double, double)
17 declare double @llvm.log.f64(double)
18 declare double @llvm.exp.f64(double)
19 declare i32 @llvm.lround(double)
23 ; CHECK-LABEL: fp128libcalls:
24 define fp128 @fp128libcalls(fp128 %x, fp128 %y) {
26 ; CHECK: call __addtf3
27 %a = fadd fp128 %x, %y
28 ; CHECK: call __multf3
29 %b = fmul fp128 %a, %y
30 ; CHECK: call __divtf3
31 %c = fdiv fp128 %b, %y
34 %d = call fp128 @llvm.sqrt.f128(fp128 %c)
36 %e = call fp128 @llvm.floor.f128(fp128 %d)
38 %f = call fp128 @llvm.pow.f128(fp128 %e, fp128 %y)
40 %g = call fp128 @llvm.trunc.f128(fp128 %f)
41 ; CHECK: call nearbyintl
42 %h = call fp128 @llvm.nearbyint.f128(fp128 %g)
46 ; CHECK-LABEL: i128libcalls:
47 define i128 @i128libcalls(i128 %x, i128 %y) {
48 ; Basic ops should be expanded
51 ; CHECK: call __multi3
53 ; CHECK: call __umodti3
58 ; CHECK-LABEL: f64libcalls:
59 define i32 @f64libcalls(double %x, double %y) {
60 ; CHECK: f64.call $push{{[0-9]}}=, cos
61 %a = call double @llvm.cos.f64(double %x)
62 ; CHECK: f64.call $push{{[0-9]}}=, log10
63 %b = call double @llvm.log10.f64(double %a)
64 ; CHECK: f64.call $push{{[0-9]}}=, pow
65 %c = call double @llvm.pow.f64(double %b, double %y)
66 ; CHECK: f64.call $push{{[0-9]}}=, log
67 %d = call double @llvm.log.f64(double %c)
68 ; CHECK: f64.call $push{{[0-9]}}=, exp
69 %e = call double @llvm.exp.f64(double %d)
70 ; CHECK: i32.call $push{{[0-9]}}=, lround
71 %f = call i32 @llvm.lround(double %e)
75 ; fcmp ord and unord (RTLIB::O_F32 / RTLIB::UO_F32 etc) are a special case (see
76 ; comment in WebAssemblyRunimeLibcallSignatures.cpp) so check them separately.
77 ; no libcalls are needed for f32 and f64
79 ; CHECK-LABEL: unordd:
80 define i1 @unordd(double %x, double %y) {
83 %a = fcmp uno double %x, %y
86 %b = fcmp ord double %x, %y
92 ; CHECK-LABEL: unordf:
93 define i1 @unordf(float %x, float %y) {
96 %a = fcmp uno float %x, %y
99 %b = fcmp ord float %x, %y
105 ; CHECK-LABEL: unordt:
106 define i1 @unordt(fp128 %x, fp128 %y) {
107 ; CHECK: i32.call $push[[CALL:[0-9]]]=, __unordtf2
108 ; CHECK-NEXT: i32.const $push[[ZERO:[0-9]+]]=, 0
109 ; CHECK-NEXT: i32.ne $push{{[0-9]}}=, $pop[[CALL]], $pop[[ZERO]]
110 %a = fcmp uno fp128 %x, %y
115 define i1 @ordt(fp128 %x, fp128 %y) {
116 ; CHECK: i32.call $push[[CALL:[0-9]]]=, __unordtf2
117 ; CHECK-NEXT: i32.eqz $push{{[0-9]}}=, $pop[[CALL]]
118 %a = fcmp ord fp128 %x, %y