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 32-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 float @llvm.fabs.f32(float)
|
|
|
|
declare float @llvm.copysign.f32(float, float)
|
|
|
|
declare float @llvm.sqrt.f32(float)
|
2015-08-25 02:23:13 +08:00
|
|
|
declare float @llvm.ceil.f32(float)
|
|
|
|
declare float @llvm.floor.f32(float)
|
|
|
|
declare float @llvm.trunc.f32(float)
|
|
|
|
declare float @llvm.nearbyint.f32(float)
|
|
|
|
declare float @llvm.rint.f32(float)
|
2015-12-10 12:52:33 +08:00
|
|
|
declare float @llvm.fma.f32(float, float, float)
|
2015-08-11 10:45:15 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fadd32:
|
2015-11-24 00:50:18 +08:00
|
|
|
; CHECK-NEXT: .param f32, f32{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .result f32{{$}}
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 0{{$}}
|
|
|
|
; CHECK-NEXT: get_local $push[[L1:[0-9]+]]=, 1{{$}}
|
|
|
|
; CHECK-NEXT: f32.add $push[[LR:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fadd32(float %x, float %y) {
|
|
|
|
%a = fadd float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fsub32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @fsub32(float %x, float %y) {
|
|
|
|
%a = fsub float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fmul32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @fmul32(float %x, float %y) {
|
|
|
|
%a = fmul float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fdiv32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @fdiv32(float %x, float %y) {
|
|
|
|
%a = fdiv float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fabs32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.abs $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fabs32(float %x) {
|
|
|
|
%a = call float @llvm.fabs.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fneg32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.neg $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fneg32(float %x) {
|
|
|
|
%a = fsub float -0., %x
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: copysign32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @copysign32(float %x, float %y) {
|
|
|
|
%a = call float @llvm.copysign.f32(float %x, float %y)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: sqrt32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.sqrt $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @sqrt32(float %x) {
|
|
|
|
%a = call float @llvm.sqrt.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
2015-08-25 02:23:13 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: ceil32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.ceil $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @ceil32(float %x) {
|
|
|
|
%a = call float @llvm.ceil.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: floor32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.floor $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @floor32(float %x) {
|
|
|
|
%a = call float @llvm.floor.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: trunc32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.trunc $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @trunc32(float %x) {
|
|
|
|
%a = call float @llvm.trunc.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define float @nearest32(float %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call float @llvm.nearbyint.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest32_via_rint:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.nearest $push[[LR:[0-9]+]]=, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define float @nearest32_via_rint(float %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call float @llvm.rint.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
2015-11-11 05:40:21 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: fmin32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @fmin32(float %x) {
|
|
|
|
%a = fcmp ult float %x, 0.0
|
|
|
|
%b = select i1 %a, float %x, float 0.0
|
|
|
|
ret float %b
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: fmax32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: f32.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 float @fmax32(float %x) {
|
|
|
|
%a = fcmp ugt float %x, 0.0
|
|
|
|
%b = select i1 %a, float %x, float 0.0
|
|
|
|
ret float %b
|
|
|
|
}
|
2015-12-10 12:52:33 +08:00
|
|
|
|
2018-10-13 15:26:10 +08:00
|
|
|
; CHECK-LABEL: fmin32_intrinsic:
|
|
|
|
; CHECK: f32.min $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop0{{$}}
|
|
|
|
declare float @llvm.minimum.f32(float, float)
|
|
|
|
define float @fmin32_intrinsic(float %x, float %y) {
|
|
|
|
%a = call float @llvm.minimum.f32(float %x, float %y)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: fmax32_intrinsic:
|
|
|
|
; CHECK: f32.max $push0=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop0{{$}}
|
|
|
|
declare float @llvm.maximum.f32(float, float)
|
|
|
|
define float @fmax32_intrinsic(float %x, float %y) {
|
|
|
|
%a = call float @llvm.maximum.f32(float %x, float %y)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-12-10 12:52:33 +08:00
|
|
|
; CHECK-LABEL: fma32:
|
2017-02-25 07:18:00 +08:00
|
|
|
; CHECK: {{^}} f32.call $push[[LR:[0-9]+]]=, fmaf@FUNCTION, $pop{{[0-9]+}}, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[LR]]{{$}}
|
2015-12-10 12:52:33 +08:00
|
|
|
define float @fma32(float %a, float %b, float %c) {
|
|
|
|
%d = call float @llvm.fma.f32(float %a, float %b, float %c)
|
|
|
|
ret float %d
|
|
|
|
}
|