blob: 6b8b9fcd5b7ffd061eea3b19c3e510c781fd0e37 [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{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000021; CHECK-NEXT: .local f64, f64, f64{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000022; CHECK-NEXT: get_local push, 1{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000023; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000024; CHECK-NEXT: get_local push, 0{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000025; CHECK-NEXT: set_local 3, pop{{$}}
Dan Gohman4b96d8d2015-11-06 19:45:01 +000026; CHECK-NEXT: add push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000027; CHECK-NEXT: set_local 4, pop{{$}}
28; CHECK-NEXT: return (get_local 4){{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000029define double @fadd64(double %x, double %y) {
30 %a = fadd double %x, %y
31 ret double %a
32}
33
Dan Gohmane51c0582015-10-06 00:27:55 +000034; CHECK-LABEL: fsub64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000035; CHECK: sub push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000036; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000037define double @fsub64(double %x, double %y) {
38 %a = fsub double %x, %y
39 ret double %a
40}
41
Dan Gohmane51c0582015-10-06 00:27:55 +000042; CHECK-LABEL: fmul64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000043; CHECK: mul push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000044; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000045define double @fmul64(double %x, double %y) {
46 %a = fmul double %x, %y
47 ret double %a
48}
49
Dan Gohmane51c0582015-10-06 00:27:55 +000050; CHECK-LABEL: fdiv64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000051; CHECK: div push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000052; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000053define double @fdiv64(double %x, double %y) {
54 %a = fdiv double %x, %y
55 ret double %a
56}
57
Dan Gohmane51c0582015-10-06 00:27:55 +000058; CHECK-LABEL: fabs64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000059; CHECK: abs push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000060; CHECK-NEXT: set_local 2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000061define double @fabs64(double %x) {
62 %a = call double @llvm.fabs.f64(double %x)
63 ret double %a
64}
65
Dan Gohmane51c0582015-10-06 00:27:55 +000066; CHECK-LABEL: fneg64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000067; CHECK: neg push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000068; CHECK-NEXT: set_local 2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000069define double @fneg64(double %x) {
70 %a = fsub double -0., %x
71 ret double %a
72}
73
Dan Gohmane51c0582015-10-06 00:27:55 +000074; CHECK-LABEL: copysign64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000075; CHECK: copysign push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000076; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000077define double @copysign64(double %x, double %y) {
78 %a = call double @llvm.copysign.f64(double %x, double %y)
79 ret double %a
80}
81
Dan Gohmane51c0582015-10-06 00:27:55 +000082; CHECK-LABEL: sqrt64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000083; CHECK: sqrt push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000084; CHECK-NEXT: set_local 2, pop{{$}}
JF Bastienef172fc2015-08-11 02:45:15 +000085define double @sqrt64(double %x) {
86 %a = call double @llvm.sqrt.f64(double %x)
87 ret double %a
88}
Dan Gohman896e53f2015-08-24 18:23:13 +000089
Dan Gohmane51c0582015-10-06 00:27:55 +000090; CHECK-LABEL: ceil64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000091; CHECK: ceil push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000092; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +000093define double @ceil64(double %x) {
94 %a = call double @llvm.ceil.f64(double %x)
95 ret double %a
96}
97
Dan Gohmane51c0582015-10-06 00:27:55 +000098; CHECK-LABEL: floor64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +000099; CHECK: floor push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000100; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +0000101define double @floor64(double %x) {
102 %a = call double @llvm.floor.f64(double %x)
103 ret double %a
104}
105
Dan Gohmane51c0582015-10-06 00:27:55 +0000106; CHECK-LABEL: trunc64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +0000107; CHECK: trunc push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000108; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman896e53f2015-08-24 18:23:13 +0000109define double @trunc64(double %x) {
110 %a = call double @llvm.trunc.f64(double %x)
111 ret double %a
112}
113
Dan Gohmane51c0582015-10-06 00:27:55 +0000114; CHECK-LABEL: nearest64:
Dan Gohman4b96d8d2015-11-06 19:45:01 +0000115; CHECK: nearest push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000116; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohmand0bf9812015-09-26 01:09:44 +0000117define double @nearest64(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000118 %a = call double @llvm.nearbyint.f64(double %x)
119 ret double %a
120}
121
Dan Gohmane51c0582015-10-06 00:27:55 +0000122; CHECK-LABEL: nearest64_via_rint:
Dan Gohman4b96d8d2015-11-06 19:45:01 +0000123; CHECK: nearest push, (get_local 1){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000124; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohmand0bf9812015-09-26 01:09:44 +0000125define double @nearest64_via_rint(double %x) {
Dan Gohman896e53f2015-08-24 18:23:13 +0000126 %a = call double @llvm.rint.f64(double %x)
127 ret double %a
128}