summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/WebAssembly/fp32.ll
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2015-08-11 02:45:15 +0000
committerJF Bastien <jfb@google.com>2015-08-11 02:45:15 +0000
commitef172fc9f003e5ad6f8ed10eb799879b99076e19 (patch)
tree2c776f4a53f244c7b0df6d89e690090cf0fdd90c /llvm/test/CodeGen/WebAssembly/fp32.ll
parent26cee3d9299a8bac3e8118b29a1072c7f169ff08 (diff)
downloadbcm5719-llvm-ef172fc9f003e5ad6f8ed10eb799879b99076e19.tar.gz
bcm5719-llvm-ef172fc9f003e5ad6f8ed10eb799879b99076e19.zip
WebAssembly: add basic floating-point tests
Summary: I somehow forgot to add these when I added the basic floating-point opcodes. Also remove ceil/floor/trunc/nearestint for now, and add them only when properly tested. Subscribers: llvm-commits, sunfish, jfb Differential Revision: http://reviews.llvm.org/D11927 llvm-svn: 244562
Diffstat (limited to 'llvm/test/CodeGen/WebAssembly/fp32.ll')
-rw-r--r--llvm/test/CodeGen/WebAssembly/fp32.ll69
1 files changed, 69 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/fp32.ll b/llvm/test/CodeGen/WebAssembly/fp32.ll
new file mode 100644
index 00000000000..f23dfd989c7
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/fp32.ll
@@ -0,0 +1,69 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that basic 32-bit floating-point operations assemble as expected.
+
+target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare float @llvm.fabs.f32(float)
+declare float @llvm.copysign.f32(float, float)
+declare float @llvm.sqrt.f32(float)
+
+; CHECK-LABEL: fadd32:
+; CHECK-NEXT: (setlocal @0 (argument 1))
+; CHECK-NEXT: (setlocal @1 (argument 0))
+; CHECK-NEXT: (setlocal @2 (fadd @1 @0))
+; CHECK-NEXT: (return @2)
+define float @fadd32(float %x, float %y) {
+ %a = fadd float %x, %y
+ ret float %a
+}
+
+; CHECK-LABEL: fsub32:
+; CHECK: (setlocal @2 (fsub @1 @0))
+define float @fsub32(float %x, float %y) {
+ %a = fsub float %x, %y
+ ret float %a
+}
+
+; CHECK-LABEL: fmul32:
+; CHECK: (setlocal @2 (fmul @1 @0))
+define float @fmul32(float %x, float %y) {
+ %a = fmul float %x, %y
+ ret float %a
+}
+
+; CHECK-LABEL: fdiv32:
+; CHECK: (setlocal @2 (fdiv @1 @0))
+define float @fdiv32(float %x, float %y) {
+ %a = fdiv float %x, %y
+ ret float %a
+}
+
+; CHECK-LABEL: fabs32:
+; CHECK: (setlocal @1 (fabs @0))
+define float @fabs32(float %x) {
+ %a = call float @llvm.fabs.f32(float %x)
+ ret float %a
+}
+
+; CHECK-LABEL: fneg32:
+; CHECK: (setlocal @1 (fneg @0))
+define float @fneg32(float %x) {
+ %a = fsub float -0., %x
+ ret float %a
+}
+
+; CHECK-LABEL: copysign32:
+; CHECK: (setlocal @2 (copysign @1 @0))
+define float @copysign32(float %x, float %y) {
+ %a = call float @llvm.copysign.f32(float %x, float %y)
+ ret float %a
+}
+
+; CHECK-LABEL: sqrt32:
+; CHECK: (setlocal @1 (sqrt @0))
+define float @sqrt32(float %x) {
+ %a = call float @llvm.sqrt.f32(float %x)
+ ret float %a
+}
OpenPOWER on IntegriCloud