blob: 10b1650b3cba87531d4792cf31eff4caafc90fcf [file] [log] [blame]
JF Bastienef172fc2015-08-11 02:45:15 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that basic 64-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 double @llvm.fabs.f64(double)
9declare double @llvm.copysign.f64(double, double)
10declare double @llvm.sqrt.f64(double)
Dan Gohman896e53f2015-08-24 18:23:13 +000011declare double @llvm.ceil.f64(double)
12declare double @llvm.floor.f64(double)
13declare double @llvm.trunc.f64(double)
14declare double @llvm.nearbyint.f64(double)
15declare double @llvm.rint.f64(double)
JF Bastienef172fc2015-08-11 02:45:15 +000016
JF Bastienb6091df2015-08-25 22:58:05 +000017; CHECK-LABEL: (func $fadd64
18; CHECK-NEXT: (param f64) (param f64) (result f64)
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 double @fadd64(double %x, double %y) {
24 %a = fadd double %x, %y
25 ret double %a
26}
27
JF Bastienb6091df2015-08-25 22:58:05 +000028; CHECK-LABEL: (func $fsub64
Dan Gohman6a050f32015-10-03 00:01:53 +000029; CHECK: (set_local @2 (fsub @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000030define double @fsub64(double %x, double %y) {
31 %a = fsub double %x, %y
32 ret double %a
33}
34
JF Bastienb6091df2015-08-25 22:58:05 +000035; CHECK-LABEL: (func $fmul64
Dan Gohman6a050f32015-10-03 00:01:53 +000036; CHECK: (set_local @2 (fmul @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000037define double @fmul64(double %x, double %y) {
38 %a = fmul double %x, %y
39 ret double %a
40}
41
JF Bastienb6091df2015-08-25 22:58:05 +000042; CHECK-LABEL: (func $fdiv64
Dan Gohman6a050f32015-10-03 00:01:53 +000043; CHECK: (set_local @2 (fdiv @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000044define double @fdiv64(double %x, double %y) {
45 %a = fdiv double %x, %y
46 ret double %a
47}
48
JF Bastienb6091df2015-08-25 22:58:05 +000049; CHECK-LABEL: (func $fabs64
Dan Gohman6a050f32015-10-03 00:01:53 +000050; CHECK: (set_local @1 (fabs @0))
JF Bastienef172fc2015-08-11 02:45:15 +000051define double @fabs64(double %x) {
52 %a = call double @llvm.fabs.f64(double %x)
53 ret double %a
54}
55
JF Bastienb6091df2015-08-25 22:58:05 +000056; CHECK-LABEL: (func $fneg64
Dan Gohman6a050f32015-10-03 00:01:53 +000057; CHECK: (set_local @1 (fneg @0))
JF Bastienef172fc2015-08-11 02:45:15 +000058define double @fneg64(double %x) {
59 %a = fsub double -0., %x
60 ret double %a
61}
62
JF Bastienb6091df2015-08-25 22:58:05 +000063; CHECK-LABEL: (func $copysign64
Dan Gohman6a050f32015-10-03 00:01:53 +000064; CHECK: (set_local @2 (copysign @1 @0))
JF Bastienef172fc2015-08-11 02:45:15 +000065define double @copysign64(double %x, double %y) {
66 %a = call double @llvm.copysign.f64(double %x, double %y)
67 ret double %a
68}
69
JF Bastienb6091df2015-08-25 22:58:05 +000070; CHECK-LABEL: (func $sqrt64
Dan Gohman6a050f32015-10-03 00:01:53 +000071; CHECK: (set_local @1 (sqrt @0))
JF Bastienef172fc2015-08-11 02:45:15 +000072define double @sqrt64(double %x) {
73 %a = call double @llvm.sqrt.f64(double %x)
74 ret double %a
75}
Dan Gohman896e53f2015-08-24 18:23:13 +000076
JF Bastienb6091df2015-08-25 22:58:05 +000077; CHECK-LABEL: (func $ceil64
Dan Gohman6a050f32015-10-03 00:01:53 +000078; CHECK: (set_local @1 (ceil @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000079define double @ceil64(double %x) {
80 %a = call double @llvm.ceil.f64(double %x)
81 ret double %a
82}
83
JF Bastienb6091df2015-08-25 22:58:05 +000084; CHECK-LABEL: (func $floor64
Dan Gohman6a050f32015-10-03 00:01:53 +000085; CHECK: (set_local @1 (floor @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000086define double @floor64(double %x) {
87 %a = call double @llvm.floor.f64(double %x)
88 ret double %a
89}
90
JF Bastienb6091df2015-08-25 22:58:05 +000091; CHECK-LABEL: (func $trunc64
Dan Gohman6a050f32015-10-03 00:01:53 +000092; CHECK: (set_local @1 (trunc @0))
Dan Gohman896e53f2015-08-24 18:23:13 +000093define double @trunc64(double %x) {
94 %a = call double @llvm.trunc.f64(double %x)
95 ret double %a
96}
97
Dan Gohmand0bf9812015-09-26 01:09:44 +000098; CHECK-LABEL: (func $nearest64
Dan Gohman6a050f32015-10-03 00:01:53 +000099; CHECK: (set_local @1 (nearest @0))
Dan Gohmand0bf9812015-09-26 01:09:44 +0000100define double @nearest64(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000101 %a = call double @llvm.nearbyint.f64(double %x)
102 ret double %a
103}
104
Dan Gohmand0bf9812015-09-26 01:09:44 +0000105; CHECK-LABEL: (func $nearest64_via_rint
Dan Gohman6a050f32015-10-03 00:01:53 +0000106; CHECK: (set_local @1 (nearest @0))
Dan Gohmand0bf9812015-09-26 01:09:44 +0000107define double @nearest64_via_rint(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000108 %a = call double @llvm.rint.f64(double %x)
109 ret double %a
110}