Dan Gohman | b7c2400 | 2016-05-21 00:21:56 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 2 | |
| 3 | ; Test that basic 64-bit floating-point operations assemble as expected. |
| 4 | |
Dan Gohman | 0c6f5ac | 2016-01-07 03:19:23 +0000 | [diff] [blame] | 5 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 6 | target triple = "wasm32-unknown-unknown" |
| 7 | |
| 8 | declare double @llvm.fabs.f64(double) |
| 9 | declare double @llvm.copysign.f64(double, double) |
| 10 | declare double @llvm.sqrt.f64(double) |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 11 | declare double @llvm.ceil.f64(double) |
| 12 | declare double @llvm.floor.f64(double) |
| 13 | declare double @llvm.trunc.f64(double) |
| 14 | declare double @llvm.nearbyint.f64(double) |
| 15 | declare double @llvm.rint.f64(double) |
Dan Gohman | 9341c1d | 2015-12-10 04:52:33 +0000 | [diff] [blame] | 16 | declare double @llvm.fma.f64(double, double, double) |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 17 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 18 | ; CHECK-LABEL: fadd64: |
Dan Gohman | 53828fd | 2015-11-23 16:50:18 +0000 | [diff] [blame] | 19 | ; CHECK-NEXT: .param f64, f64{{$}} |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 20 | ; CHECK-NEXT: .result f64{{$}} |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 21 | ; CHECK-NEXT: f64.add $push0=, $0, $1{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 22 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 23 | define double @fadd64(double %x, double %y) { |
| 24 | %a = fadd double %x, %y |
| 25 | ret double %a |
| 26 | } |
| 27 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 28 | ; CHECK-LABEL: fsub64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 29 | ; CHECK: f64.sub $push0=, $0, $1{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 30 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 31 | define double @fsub64(double %x, double %y) { |
| 32 | %a = fsub double %x, %y |
| 33 | ret double %a |
| 34 | } |
| 35 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 36 | ; CHECK-LABEL: fmul64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 37 | ; CHECK: f64.mul $push0=, $0, $1{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 38 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 39 | define double @fmul64(double %x, double %y) { |
| 40 | %a = fmul double %x, %y |
| 41 | ret double %a |
| 42 | } |
| 43 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 44 | ; CHECK-LABEL: fdiv64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 45 | ; CHECK: f64.div $push0=, $0, $1{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 46 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 47 | define double @fdiv64(double %x, double %y) { |
| 48 | %a = fdiv double %x, %y |
| 49 | ret double %a |
| 50 | } |
| 51 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 52 | ; CHECK-LABEL: fabs64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 53 | ; CHECK: f64.abs $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 54 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 55 | define double @fabs64(double %x) { |
| 56 | %a = call double @llvm.fabs.f64(double %x) |
| 57 | ret double %a |
| 58 | } |
| 59 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 60 | ; CHECK-LABEL: fneg64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 61 | ; CHECK: f64.neg $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 62 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 63 | define double @fneg64(double %x) { |
| 64 | %a = fsub double -0., %x |
| 65 | ret double %a |
| 66 | } |
| 67 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 68 | ; CHECK-LABEL: copysign64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 69 | ; CHECK: f64.copysign $push0=, $0, $1{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 70 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 71 | define double @copysign64(double %x, double %y) { |
| 72 | %a = call double @llvm.copysign.f64(double %x, double %y) |
| 73 | ret double %a |
| 74 | } |
| 75 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 76 | ; CHECK-LABEL: sqrt64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 77 | ; CHECK: f64.sqrt $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 78 | ; CHECK-NEXT: return $pop0{{$}} |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 79 | define double @sqrt64(double %x) { |
| 80 | %a = call double @llvm.sqrt.f64(double %x) |
| 81 | ret double %a |
| 82 | } |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 83 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 84 | ; CHECK-LABEL: ceil64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 85 | ; CHECK: f64.ceil $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 86 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 87 | define double @ceil64(double %x) { |
| 88 | %a = call double @llvm.ceil.f64(double %x) |
| 89 | ret double %a |
| 90 | } |
| 91 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 92 | ; CHECK-LABEL: floor64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 93 | ; CHECK: f64.floor $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 94 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 95 | define double @floor64(double %x) { |
| 96 | %a = call double @llvm.floor.f64(double %x) |
| 97 | ret double %a |
| 98 | } |
| 99 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 100 | ; CHECK-LABEL: trunc64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 101 | ; CHECK: f64.trunc $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 102 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 103 | define double @trunc64(double %x) { |
| 104 | %a = call double @llvm.trunc.f64(double %x) |
| 105 | ret double %a |
| 106 | } |
| 107 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 108 | ; CHECK-LABEL: nearest64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 109 | ; CHECK: f64.nearest $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 110 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame] | 111 | define double @nearest64(double %x) { |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 112 | %a = call double @llvm.nearbyint.f64(double %x) |
| 113 | ret double %a |
| 114 | } |
| 115 | |
Dan Gohman | e51c058 | 2015-10-06 00:27:55 +0000 | [diff] [blame] | 116 | ; CHECK-LABEL: nearest64_via_rint: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 117 | ; CHECK: f64.nearest $push0=, $0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 118 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame] | 119 | define double @nearest64_via_rint(double %x) { |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 120 | %a = call double @llvm.rint.f64(double %x) |
| 121 | ret double %a |
| 122 | } |
Dan Gohman | b84ae9b | 2015-11-10 21:40:21 +0000 | [diff] [blame] | 123 | |
| 124 | ; Min and max tests. LLVM currently only forms fminnan and fmaxnan nodes in |
| 125 | ; cases where there's a single fcmp with a select and it can prove that one |
| 126 | ; of the arms is never NaN, so we only test that case. In the future if LLVM |
| 127 | ; learns to form fminnan/fmaxnan in more cases, we can write more general |
| 128 | ; tests. |
| 129 | |
| 130 | ; CHECK-LABEL: fmin64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 131 | ; CHECK: f64.min $push1=, $0, $pop0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 132 | ; CHECK-NEXT: return $pop1{{$}} |
Dan Gohman | b84ae9b | 2015-11-10 21:40:21 +0000 | [diff] [blame] | 133 | define double @fmin64(double %x) { |
| 134 | %a = fcmp ult double %x, 0.0 |
| 135 | %b = select i1 %a, double %x, double 0.0 |
| 136 | ret double %b |
| 137 | } |
| 138 | |
| 139 | ; CHECK-LABEL: fmax64: |
Dan Gohman | 700515f | 2015-11-23 21:55:57 +0000 | [diff] [blame] | 140 | ; CHECK: f64.max $push1=, $0, $pop0{{$}} |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 141 | ; CHECK-NEXT: return $pop1{{$}} |
Dan Gohman | b84ae9b | 2015-11-10 21:40:21 +0000 | [diff] [blame] | 142 | define double @fmax64(double %x) { |
| 143 | %a = fcmp ugt double %x, 0.0 |
| 144 | %b = select i1 %a, double %x, double 0.0 |
| 145 | ret double %b |
| 146 | } |
Dan Gohman | 9341c1d | 2015-12-10 04:52:33 +0000 | [diff] [blame] | 147 | |
| 148 | ; CHECK-LABEL: fma64: |
Dan Gohman | 26c6765 | 2016-01-11 23:38:05 +0000 | [diff] [blame] | 149 | ; CHECK: {{^}} f64.call $push0=, fma@FUNCTION, $0, $1, $2{{$}} |
Dan Gohman | 9341c1d | 2015-12-10 04:52:33 +0000 | [diff] [blame] | 150 | ; CHECK-NEXT: return $pop0{{$}} |
| 151 | define double @fma64(double %a, double %b, double %c) { |
| 152 | %d = call double @llvm.fma.f64(double %a, double %b, double %c) |
| 153 | ret double %d |
| 154 | } |