2018-08-27 23:45:51 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
|
2015-08-11 10:45:15 +08:00
|
|
|
|
|
|
|
; Test that basic 64-bit floating-point operations assemble as expected.
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2018-05-11 01:49:11 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2015-08-11 10:45:15 +08:00
|
|
|
|
|
|
|
declare double @llvm.fabs.f64(double)
|
|
|
|
declare double @llvm.copysign.f64(double, double)
|
|
|
|
declare double @llvm.sqrt.f64(double)
|
2015-08-25 02:23:13 +08:00
|
|
|
declare double @llvm.ceil.f64(double)
|
|
|
|
declare double @llvm.floor.f64(double)
|
|
|
|
declare double @llvm.trunc.f64(double)
|
|
|
|
declare double @llvm.nearbyint.f64(double)
|
|
|
|
declare double @llvm.rint.f64(double)
|
2015-12-10 12:52:33 +08:00
|
|
|
declare double @llvm.fma.f64(double, double, double)
|
2015-08-11 10:45:15 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fadd64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype fadd64 (f64, f64) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}}
|
|
|
|
; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}}
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK-NEXT: f64.add $push[[LR:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fadd64(double %x, double %y) {
|
|
|
|
%a = fadd double %x, %y
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fsub64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.sub $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fsub64(double %x, double %y) {
|
|
|
|
%a = fsub double %x, %y
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fmul64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.mul $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fmul64(double %x, double %y) {
|
|
|
|
%a = fmul double %x, %y
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fdiv64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.div $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fdiv64(double %x, double %y) {
|
|
|
|
%a = fdiv double %x, %y
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fabs64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.abs $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fabs64(double %x) {
|
|
|
|
%a = call double @llvm.fabs.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fneg64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.neg $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @fneg64(double %x) {
|
|
|
|
%a = fsub double -0., %x
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: copysign64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.copysign $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @copysign64(double %x, double %y) {
|
|
|
|
%a = call double @llvm.copysign.f64(double %x, double %y)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: sqrt64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.sqrt $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define double @sqrt64(double %x) {
|
|
|
|
%a = call double @llvm.sqrt.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
2015-08-25 02:23:13 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: ceil64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.ceil $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define double @ceil64(double %x) {
|
|
|
|
%a = call double @llvm.ceil.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: floor64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.floor $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define double @floor64(double %x) {
|
|
|
|
%a = call double @llvm.floor.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: trunc64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.trunc $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define double @trunc64(double %x) {
|
|
|
|
%a = call double @llvm.trunc.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define double @nearest64(double %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call double @llvm.nearbyint.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest64_via_rint:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define double @nearest64_via_rint(double %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call double @llvm.rint.f64(double %x)
|
|
|
|
ret double %a
|
|
|
|
}
|
2015-11-11 05:40:21 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: fmin64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.min $push1=, $pop{{[0-9]+}}, $pop[[LR]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop1{{$}}
|
2015-11-11 05:40:21 +08:00
|
|
|
define double @fmin64(double %x) {
|
|
|
|
%a = fcmp ult double %x, 0.0
|
|
|
|
%b = select i1 %a, double %x, double 0.0
|
|
|
|
ret double %b
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: fmax64:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f64.max $push1=, $pop{{[0-9]+}}, $pop[[LR]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop1{{$}}
|
2015-11-11 05:40:21 +08:00
|
|
|
define double @fmax64(double %x) {
|
|
|
|
%a = fcmp ugt double %x, 0.0
|
|
|
|
%b = select i1 %a, double %x, double 0.0
|
|
|
|
ret double %b
|
|
|
|
}
|
2015-12-10 12:52:33 +08:00
|
|
|
|
2018-10-13 15:26:10 +08:00
|
|
|
; CHECK-LABEL: fmin64_intrinsic:
|
|
|
|
; CHECK: f64.min $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop0{{$}}
|
|
|
|
declare double @llvm.minimum.f64(double, double)
|
|
|
|
define double @fmin64_intrinsic(double %x, double %y) {
|
|
|
|
%a = call double @llvm.minimum.f64(double %x, double %y)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: fmax64_intrinsic:
|
|
|
|
; CHECK: f64.max $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop0{{$}}
|
|
|
|
declare double @llvm.maximum.f64(double, double)
|
|
|
|
define double @fmax64_intrinsic(double %x, double %y) {
|
|
|
|
%a = call double @llvm.maximum.f64(double %x, double %y)
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-12-10 12:52:33 +08:00
|
|
|
; CHECK-LABEL: fma64:
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: {{^}} call $push[[LR:[0-9]+]]=, fma, $pop{{[0-9]+}}, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-12-10 12:52:33 +08:00
|
|
|
define double @fma64(double %a, double %b, double %c) {
|
|
|
|
%d = call double @llvm.fma.f64(double %a, double %b, double %c)
|
|
|
|
ret double %d
|
|
|
|
}
|