blob: 3590e45fd85f21d62b4be1389c1f694a73930fdf [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
Dan Gohmane51c0582015-10-06 00:27:55 +000017; CHECK-LABEL: fadd64:
18; CHECK-NEXT: .param f64{{$}}
19; CHECK-NEXT: .param f64{{$}}
20; CHECK-NEXT: .result f64{{$}}
21; CHECK-NEXT: @1{{$}}
22; CHECK-NEXT: set_local @2, pop{{$}}
23; CHECK-NEXT: @0{{$}}
24; CHECK-NEXT: set_local @3, pop{{$}}
Dan Gohmanee1588c2015-10-09 17:50:00 +000025; CHECK-NEXT: add @3, @2{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000026; CHECK-NEXT: set_local @4, pop{{$}}
27; CHECK-NEXT: return @4{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000028define double @fadd64(double %x, double %y) {
29 %a = fadd double %x, %y
30 ret double %a
31}
32
Dan Gohmane51c0582015-10-06 00:27:55 +000033; CHECK-LABEL: fsub64:
Dan Gohmanee1588c2015-10-09 17:50:00 +000034; CHECK: sub @3, @2{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000035; CHECK-NEXT: set_local @4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000036define double @fsub64(double %x, double %y) {
37 %a = fsub double %x, %y
38 ret double %a
39}
40
Dan Gohmane51c0582015-10-06 00:27:55 +000041; CHECK-LABEL: fmul64:
Dan Gohmanee1588c2015-10-09 17:50:00 +000042; CHECK: mul @3, @2{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000043; CHECK-NEXT: set_local @4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000044define double @fmul64(double %x, double %y) {
45 %a = fmul double %x, %y
46 ret double %a
47}
48
Dan Gohmane51c0582015-10-06 00:27:55 +000049; CHECK-LABEL: fdiv64:
Dan Gohmanee1588c2015-10-09 17:50:00 +000050; CHECK: div @3, @2{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000051; CHECK-NEXT: set_local @4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000052define double @fdiv64(double %x, double %y) {
53 %a = fdiv double %x, %y
54 ret double %a
55}
56
Dan Gohmane51c0582015-10-06 00:27:55 +000057; CHECK-LABEL: fabs64:
Dan Gohmanee1588c2015-10-09 17:50:00 +000058; CHECK: abs @1{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000059; CHECK-NEXT: set_local @2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000060define double @fabs64(double %x) {
61 %a = call double @llvm.fabs.f64(double %x)
62 ret double %a
63}
64
Dan Gohmane51c0582015-10-06 00:27:55 +000065; CHECK-LABEL: fneg64:
Dan Gohmanee1588c2015-10-09 17:50:00 +000066; CHECK: neg @1{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000067; CHECK-NEXT: set_local @2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000068define double @fneg64(double %x) {
69 %a = fsub double -0., %x
70 ret double %a
71}
72
Dan Gohmane51c0582015-10-06 00:27:55 +000073; CHECK-LABEL: copysign64:
74; CHECK: copysign @3, @2{{$}}
75; CHECK-NEXT: set_local @4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000076define double @copysign64(double %x, double %y) {
77 %a = call double @llvm.copysign.f64(double %x, double %y)
78 ret double %a
79}
80
Dan Gohmane51c0582015-10-06 00:27:55 +000081; CHECK-LABEL: sqrt64:
82; CHECK: sqrt @1{{$}}
83; CHECK-NEXT: set_local @2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000084define double @sqrt64(double %x) {
85 %a = call double @llvm.sqrt.f64(double %x)
86 ret double %a
87}
Dan Gohman896e53f2015-08-24 18:23:13 +000088
Dan Gohmane51c0582015-10-06 00:27:55 +000089; CHECK-LABEL: ceil64:
90; CHECK: ceil @1{{$}}
91; CHECK-NEXT: set_local @2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +000092define double @ceil64(double %x) {
93 %a = call double @llvm.ceil.f64(double %x)
94 ret double %a
95}
96
Dan Gohmane51c0582015-10-06 00:27:55 +000097; CHECK-LABEL: floor64:
98; CHECK: floor @1{{$}}
99; CHECK-NEXT: set_local @2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +0000100define double @floor64(double %x) {
101 %a = call double @llvm.floor.f64(double %x)
102 ret double %a
103}
104
Dan Gohmane51c0582015-10-06 00:27:55 +0000105; CHECK-LABEL: trunc64:
106; CHECK: trunc @1{{$}}
107; CHECK-NEXT: set_local @2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +0000108define double @trunc64(double %x) {
109 %a = call double @llvm.trunc.f64(double %x)
110 ret double %a
111}
112
Dan Gohmane51c0582015-10-06 00:27:55 +0000113; CHECK-LABEL: nearest64:
114; CHECK: nearest @1{{$}}
115; CHECK-NEXT: set_local @2, pop{{$}}
Dan Gohmand0bf9812015-09-26 01:09:44 +0000116define double @nearest64(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000117 %a = call double @llvm.nearbyint.f64(double %x)
118 ret double %a
119}
120
Dan Gohmane51c0582015-10-06 00:27:55 +0000121; CHECK-LABEL: nearest64_via_rint:
122; CHECK: nearest @1{{$}}
123; CHECK-NEXT: set_local @2, pop{{$}}
Dan Gohmand0bf9812015-09-26 01:09:44 +0000124define double @nearest64_via_rint(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000125 %a = call double @llvm.rint.f64(double %x)
126 ret double %a
127}