2015-08-11 10:45:15 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false | FileCheck %s
|
|
|
|
|
|
|
|
; Test that basic 32-bit floating-point operations assemble as expected.
|
|
|
|
|
2015-08-20 04:30:20 +08:00
|
|
|
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
|
2015-08-11 10:45:15 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
|
|
|
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-08-11 10:45:15 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fadd32:
|
|
|
|
; CHECK-NEXT: .param f32{{$}}
|
|
|
|
; CHECK-NEXT: .param f32{{$}}
|
|
|
|
; CHECK-NEXT: .result f32{{$}}
|
|
|
|
; CHECK-NEXT: @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
|
|
|
; CHECK-NEXT: @0{{$}}
|
|
|
|
; CHECK-NEXT: set_local @3, pop{{$}}
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK-NEXT: add @3, @2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @4, pop{{$}}
|
|
|
|
; CHECK-NEXT: return @4{{$}}
|
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:
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK: sub @3, @2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @4, pop{{$}}
|
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:
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK: mul @3, @2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @4, pop{{$}}
|
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:
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK: div @3, @2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @4, pop{{$}}
|
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:
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK: abs @1{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
2015-10-10 01:50:00 +08:00
|
|
|
; CHECK: neg @1{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: copysign @3, @2{{$}}
|
|
|
|
; CHECK-NEXT: set_local @4, pop{{$}}
|
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:
|
|
|
|
; CHECK: sqrt @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: ceil @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: floor @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: trunc @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: nearest @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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:
|
|
|
|
; CHECK: nearest @1{{$}}
|
|
|
|
; CHECK-NEXT: set_local @2, pop{{$}}
|
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
|
|
|
|
}
|