1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
3 ; Test that basic 64-bit floating-point operations assemble as expected.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 declare double @llvm.fabs.f64(double)
9 declare double @llvm.copysign.f64(double, double)
10 declare double @llvm.sqrt.f64(double)
11 declare double @llvm.ceil.f64(double)
12 declare double @llvm.floor.f64(double)
13 declare double @llvm.trunc.f64(double)
14 declare double @llvm.nearbyint.f64(double)
15 declare double @llvm.rint.f64(double)
16 declare double @llvm.fma.f64(double, double, double)
18 ; CHECK-LABEL: fadd64:
19 ; CHECK-NEXT: .functype fadd64 (f64, f64) -> (f64){{$}}
20 ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}}
21 ; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}}
22 ; CHECK-NEXT: f64.add $push[[LR:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
23 ; CHECK-NEXT: return $pop[[LR]]{{$}}
24 define double @fadd64(double %x, double %y) {
25 %a = fadd double %x, %y
29 ; CHECK-LABEL: fsub64:
30 ; CHECK: f64.sub $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
31 ; CHECK-NEXT: return $pop[[LR]]{{$}}
32 define double @fsub64(double %x, double %y) {
33 %a = fsub double %x, %y
37 ; CHECK-LABEL: fmul64:
38 ; CHECK: f64.mul $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
39 ; CHECK-NEXT: return $pop[[LR]]{{$}}
40 define double @fmul64(double %x, double %y) {
41 %a = fmul double %x, %y
45 ; CHECK-LABEL: fdiv64:
46 ; CHECK: f64.div $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
47 ; CHECK-NEXT: return $pop[[LR]]{{$}}
48 define double @fdiv64(double %x, double %y) {
49 %a = fdiv double %x, %y
53 ; CHECK-LABEL: fabs64:
54 ; CHECK: f64.abs $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
55 ; CHECK-NEXT: return $pop[[LR]]{{$}}
56 define double @fabs64(double %x) {
57 %a = call double @llvm.fabs.f64(double %x)
61 ; CHECK-LABEL: fneg64:
62 ; CHECK: f64.neg $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
63 ; CHECK-NEXT: return $pop[[LR]]{{$}}
64 define double @fneg64(double %x) {
65 %a = fsub double -0., %x
69 ; CHECK-LABEL: copysign64:
70 ; CHECK: f64.copysign $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
71 ; CHECK-NEXT: return $pop[[LR]]{{$}}
72 define double @copysign64(double %x, double %y) {
73 %a = call double @llvm.copysign.f64(double %x, double %y)
77 ; CHECK-LABEL: sqrt64:
78 ; CHECK: f64.sqrt $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
79 ; CHECK-NEXT: return $pop[[LR]]{{$}}
80 define double @sqrt64(double %x) {
81 %a = call double @llvm.sqrt.f64(double %x)
85 ; CHECK-LABEL: ceil64:
86 ; CHECK: f64.ceil $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
87 ; CHECK-NEXT: return $pop[[LR]]{{$}}
88 define double @ceil64(double %x) {
89 %a = call double @llvm.ceil.f64(double %x)
93 ; CHECK-LABEL: floor64:
94 ; CHECK: f64.floor $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
95 ; CHECK-NEXT: return $pop[[LR]]{{$}}
96 define double @floor64(double %x) {
97 %a = call double @llvm.floor.f64(double %x)
101 ; CHECK-LABEL: trunc64:
102 ; CHECK: f64.trunc $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
103 ; CHECK-NEXT: return $pop[[LR]]{{$}}
104 define double @trunc64(double %x) {
105 %a = call double @llvm.trunc.f64(double %x)
109 ; CHECK-LABEL: nearest64:
110 ; CHECK: f64.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
111 ; CHECK-NEXT: return $pop[[LR]]{{$}}
112 define double @nearest64(double %x) {
113 %a = call double @llvm.nearbyint.f64(double %x)
117 ; CHECK-LABEL: nearest64_via_rint:
118 ; CHECK: f64.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
119 ; CHECK-NEXT: return $pop[[LR]]{{$}}
120 define double @nearest64_via_rint(double %x) {
121 %a = call double @llvm.rint.f64(double %x)
125 ; CHECK-LABEL: fmin64:
126 ; CHECK: f64.min $push1=, $pop{{[0-9]+}}, $pop[[LR]]{{$}}
127 ; CHECK-NEXT: return $pop1{{$}}
128 define double @fmin64(double %x) {
129 %a = fcmp ult double %x, 0.0
130 %b = select i1 %a, double %x, double 0.0
134 ; CHECK-LABEL: fmax64:
135 ; CHECK: f64.max $push1=, $pop{{[0-9]+}}, $pop[[LR]]{{$}}
136 ; CHECK-NEXT: return $pop1{{$}}
137 define double @fmax64(double %x) {
138 %a = fcmp ugt double %x, 0.0
139 %b = select i1 %a, double %x, double 0.0
143 ; CHECK-LABEL: fmin64_intrinsic:
144 ; CHECK: f64.min $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
145 ; CHECK-NEXT: return $pop0{{$}}
146 declare double @llvm.minimum.f64(double, double)
147 define double @fmin64_intrinsic(double %x, double %y) {
148 %a = call double @llvm.minimum.f64(double %x, double %y)
152 ; CHECK-LABEL: fmax64_intrinsic:
153 ; CHECK: f64.max $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
154 ; CHECK-NEXT: return $pop0{{$}}
155 declare double @llvm.maximum.f64(double, double)
156 define double @fmax64_intrinsic(double %x, double %y) {
157 %a = call double @llvm.maximum.f64(double %x, double %y)
161 ; CHECK-LABEL: fma64:
162 ; CHECK: {{^}} f64.call $push[[LR:[0-9]+]]=, fma, $pop{{[0-9]+}}, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
163 ; CHECK-NEXT: return $pop[[LR]]{{$}}
164 define double @fma64(double %a, double %b, double %c) {
165 %d = call double @llvm.fma.f64(double %a, double %b, double %c)