blob: 1ea09bad6b73858806f2d803006bdbca4184453f [file] [log] [blame]
JF Bastienef172fc2015-08-11 02:45:15 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that basic 32-bit floating-point operations assemble as expected.
4
Dan Gohmandde8dce2015-08-19 20:30:20 +00005target datalayout = "e-p:32:32-i64:64-n32:64-S128"
JF Bastienef172fc2015-08-11 02:45:15 +00006target triple = "wasm32-unknown-unknown"
7
8declare float @llvm.fabs.f32(float)
9declare float @llvm.copysign.f32(float, float)
10declare float @llvm.sqrt.f32(float)
Dan Gohman896e53f2015-08-24 18:23:13 +000011declare float @llvm.ceil.f32(float)
12declare float @llvm.floor.f32(float)
13declare float @llvm.trunc.f32(float)
14declare float @llvm.nearbyint.f32(float)
15declare float @llvm.rint.f32(float)
JF Bastienef172fc2015-08-11 02:45:15 +000016
JF Bastienb6091df2015-08-25 22:58:05 +000017; CHECK-LABEL: (func $fadd32
18; CHECK-NEXT: (param f32) (param f32) (result f32)
Dan Gohman6a050f32015-10-03 00:01:53 +000019; CHECK-NEXT: (set_local @0 (argument 1))
20; CHECK-NEXT: (set_local @1 (argument 0))
21; CHECK-NEXT: (set_local @2 (fadd @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000022; CHECK-NEXT: (return @2)
23define float @fadd32(float %x, float %y) {
24 %a = fadd float %x, %y
25 ret float %a
26}
27
JF Bastienb6091df2015-08-25 22:58:05 +000028; CHECK-LABEL: (func $fsub32
Dan Gohman6a050f32015-10-03 00:01:53 +000029; CHECK: (set_local @2 (fsub @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000030define float @fsub32(float %x, float %y) {
31 %a = fsub float %x, %y
32 ret float %a
33}
34
JF Bastienb6091df2015-08-25 22:58:05 +000035; CHECK-LABEL: (func $fmul32
Dan Gohman6a050f32015-10-03 00:01:53 +000036; CHECK: (set_local @2 (fmul @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000037define float @fmul32(float %x, float %y) {
38 %a = fmul float %x, %y
39 ret float %a
40}
41
JF Bastienb6091df2015-08-25 22:58:05 +000042; CHECK-LABEL: (func $fdiv32
Dan Gohman6a050f32015-10-03 00:01:53 +000043; CHECK: (set_local @2 (fdiv @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000044define float @fdiv32(float %x, float %y) {
45 %a = fdiv float %x, %y
46 ret float %a
47}
48
JF Bastienb6091df2015-08-25 22:58:05 +000049; CHECK-LABEL: (func $fabs32
Dan Gohman6a050f32015-10-03 00:01:53 +000050; CHECK: (set_local @1 (fabs @0))
JF Bastienef172fc2015-08-11 02:45:15 +000051define float @fabs32(float %x) {
52 %a = call float @llvm.fabs.f32(float %x)
53 ret float %a
54}
55
JF Bastienb6091df2015-08-25 22:58:05 +000056; CHECK-LABEL: (func $fneg32
Dan Gohman6a050f32015-10-03 00:01:53 +000057; CHECK: (set_local @1 (fneg @0))
JF Bastienef172fc2015-08-11 02:45:15 +000058define float @fneg32(float %x) {
59 %a = fsub float -0., %x
60 ret float %a
61}
62
JF Bastienb6091df2015-08-25 22:58:05 +000063; CHECK-LABEL: (func $copysign32
Dan Gohman6a050f32015-10-03 00:01:53 +000064; CHECK: (set_local @2 (copysign @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000065define float @copysign32(float %x, float %y) {
66 %a = call float @llvm.copysign.f32(float %x, float %y)
67 ret float %a
68}
69
JF Bastienb6091df2015-08-25 22:58:05 +000070; CHECK-LABEL: (func $sqrt32
Dan Gohman6a050f32015-10-03 00:01:53 +000071; CHECK: (set_local @1 (sqrt @0))
JF Bastienef172fc2015-08-11 02:45:15 +000072define float @sqrt32(float %x) {
73 %a = call float @llvm.sqrt.f32(float %x)
74 ret float %a
75}
Dan Gohman896e53f2015-08-24 18:23:13 +000076
JF Bastienb6091df2015-08-25 22:58:05 +000077; CHECK-LABEL: (func $ceil32
Dan Gohman6a050f32015-10-03 00:01:53 +000078; CHECK: (set_local @1 (ceil @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000079define float @ceil32(float %x) {
80 %a = call float @llvm.ceil.f32(float %x)
81 ret float %a
82}
83
JF Bastienb6091df2015-08-25 22:58:05 +000084; CHECK-LABEL: (func $floor32
Dan Gohman6a050f32015-10-03 00:01:53 +000085; CHECK: (set_local @1 (floor @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000086define float @floor32(float %x) {
87 %a = call float @llvm.floor.f32(float %x)
88 ret float %a
89}
90
JF Bastienb6091df2015-08-25 22:58:05 +000091; CHECK-LABEL: (func $trunc32
Dan Gohman6a050f32015-10-03 00:01:53 +000092; CHECK: (set_local @1 (trunc @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000093define float @trunc32(float %x) {
94 %a = call float @llvm.trunc.f32(float %x)
95 ret float %a
96}
97
Dan Gohmand0bf9812015-09-26 01:09:44 +000098; CHECK-LABEL: (func $nearest32
Dan Gohman6a050f32015-10-03 00:01:53 +000099; CHECK: (set_local @1 (nearest @0))
Dan Gohmand0bf9812015-09-26 01:09:44 +0000100define float @nearest32(float %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000101 %a = call float @llvm.nearbyint.f32(float %x)
102 ret float %a
103}
104
Dan Gohmand0bf9812015-09-26 01:09:44 +0000105; CHECK-LABEL: (func $nearest32_via_rint
Dan Gohman6a050f32015-10-03 00:01:53 +0000106; CHECK: (set_local @1 (nearest @0))
Dan Gohmand0bf9812015-09-26 01:09:44 +0000107define float @nearest32_via_rint(float %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000108 %a = call float @llvm.rint.f32(float %x)
109 ret float %a
110}