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 triple = "wasm32-unknown-unknown"
7 declare fp128 @llvm.sqrt.f128(fp128)
8 declare fp128 @llvm.floor.f128(fp128)
9 declare fp128 @llvm.trunc.f128(fp128)
10 declare fp128 @llvm.nearbyint.f128(fp128)
11 declare fp128 @llvm.pow.f128(fp128, fp128)
12 declare fp128 @llvm.powi.f128.i32(fp128, i32)
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.powi.f64.i32(double, i32)
18 declare double @llvm.log.f64(double)
19 declare double @llvm.exp.f64(double)
20 declare i32 @llvm.lround(double)
24 ; CHECK-LABEL: fp128libcalls:
25 define fp128 @fp128libcalls(fp128 %x, fp128 %y, i32 %z) {
27 ; CHECK: call __addtf3
28 %a = fadd fp128 %x, %y
29 ; CHECK: call __multf3
30 %b = fmul fp128 %a, %y
31 ; CHECK: call __divtf3
32 %c = fdiv fp128 %b, %y
35 %d = call fp128 @llvm.sqrt.f128(fp128 %c)
37 %e = call fp128 @llvm.floor.f128(fp128 %d)
39 %f = call fp128 @llvm.pow.f128(fp128 %e, fp128 %y)
40 ; CHECK: call __powitf2
41 %g = call fp128 @llvm.powi.f128.i32(fp128 %f, i32 %z)
43 %h = call fp128 @llvm.trunc.f128(fp128 %g)
44 ; CHECK: call nearbyintl
45 %i = call fp128 @llvm.nearbyint.f128(fp128 %h)
49 ; CHECK-LABEL: i128libcalls:
50 define i128 @i128libcalls(i128 %x, i128 %y) {
51 ; Basic ops should be expanded
54 ; CHECK: call __multi3
56 ; CHECK: call __umodti3
61 ; CHECK-LABEL: f64libcalls:
62 define i32 @f64libcalls(double %x, double %y, i32 %z) {
63 ; CHECK: call $push{{[0-9]}}=, cos
64 %a = call double @llvm.cos.f64(double %x)
65 ; CHECK: call $push{{[0-9]}}=, log10
66 %b = call double @llvm.log10.f64(double %a)
67 ; CHECK: call $push{{[0-9]}}=, pow
68 %c = call double @llvm.pow.f64(double %b, double %y)
69 ; CHECK: call $push{{[0-9]}}=, __powidf2
70 %d = call double @llvm.powi.f64.i32(double %c, i32 %z)
71 ; CHECK: call $push{{[0-9]}}=, log
72 %e = call double @llvm.log.f64(double %d)
73 ; CHECK: call $push{{[0-9]}}=, exp
74 %f = call double @llvm.exp.f64(double %e)
75 ; CHECK: call $push{{[0-9]}}=, cbrt
76 %g = call fast double @llvm.pow.f64(double %f, double 0x3FD5555555555555)
77 ; CHECK: call $push{{[0-9]}}=, lround
78 %h = call i32 @llvm.lround(double %g)
82 ; fcmp ord and unord (RTLIB::O_F32 / RTLIB::UO_F32 etc) are a special case (see
83 ; comment in WebAssemblyRunimeLibcallSignatures.cpp) so check them separately.
84 ; no libcalls are needed for f32 and f64
86 ; CHECK-LABEL: unordd:
87 define i1 @unordd(double %x, double %y) {
90 %a = fcmp uno double %x, %y
93 %b = fcmp ord double %x, %y
99 ; CHECK-LABEL: unordf:
100 define i1 @unordf(float %x, float %y) {
103 %a = fcmp uno float %x, %y
106 %b = fcmp ord float %x, %y
112 ; CHECK-LABEL: unordt:
113 define i1 @unordt(fp128 %x, fp128 %y) {
114 ; CHECK: call $push[[CALL:[0-9]]]=, __unordtf2
115 ; CHECK-NEXT: i32.const $push[[ZERO:[0-9]+]]=, 0
116 ; CHECK-NEXT: i32.ne $push{{[0-9]}}=, $pop[[CALL]], $pop[[ZERO]]
117 %a = fcmp uno fp128 %x, %y
122 define i1 @ordt(fp128 %x, fp128 %y) {
123 ; CHECK: call $push[[CALL:[0-9]]]=, __unordtf2
124 ; CHECK-NEXT: i32.eqz $push{{[0-9]}}=, $pop[[CALL]]
125 %a = fcmp ord fp128 %x, %y