diff options
| author | Dan Gohman <dan433584@gmail.com> | 2015-12-10 04:52:33 +0000 |
|---|---|---|
| committer | Dan Gohman <dan433584@gmail.com> | 2015-12-10 04:52:33 +0000 |
| commit | 9341c1d4b3772252bfc1f460da29c291b658e1f8 (patch) | |
| tree | fce70eddc64d729f34976addbb23b9b6803feb67 | |
| parent | 60520e22030df6dec13d6618c7be1701c3a3da14 (diff) | |
| download | bcm5719-llvm-9341c1d4b3772252bfc1f460da29c291b658e1f8.tar.gz bcm5719-llvm-9341c1d4b3772252bfc1f460da29c291b658e1f8.zip | |
[WebAssembly] Implement fma.
It is lowered to a libcall for now, but this is expected to change in the future.
llvm-svn: 255219
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/f32.ll | 9 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/f64.ll | 9 |
3 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index fae10947ec6..4ef0846d311 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -134,7 +134,7 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering( setCondCodeAction(CC, T, Expand); // Expand floating-point library function operators. for (auto Op : {ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOWI, ISD::FPOW, - ISD::FREM}) + ISD::FREM, ISD::FMA}) setOperationAction(Op, T, Expand); // Note supported floating-point library function operators that otherwise // default to expand. diff --git a/llvm/test/CodeGen/WebAssembly/f32.ll b/llvm/test/CodeGen/WebAssembly/f32.ll index a15b37beab8..10fe1856037 100644 --- a/llvm/test/CodeGen/WebAssembly/f32.ll +++ b/llvm/test/CodeGen/WebAssembly/f32.ll @@ -13,6 +13,7 @@ declare float @llvm.floor.f32(float) declare float @llvm.trunc.f32(float) declare float @llvm.nearbyint.f32(float) declare float @llvm.rint.f32(float) +declare float @llvm.fma.f32(float, float, float) ; CHECK-LABEL: fadd32: ; CHECK-NEXT: .param f32, f32{{$}} @@ -143,3 +144,11 @@ define float @fmax32(float %x) { %b = select i1 %a, float %x, float 0.0 ret float %b } + +; CHECK-LABEL: fma32: +; CHECK: call $push0=, fmaf, $0, $1, $2{{$}} +; CHECK-NEXT: return $pop0{{$}} +define float @fma32(float %a, float %b, float %c) { + %d = call float @llvm.fma.f32(float %a, float %b, float %c) + ret float %d +} diff --git a/llvm/test/CodeGen/WebAssembly/f64.ll b/llvm/test/CodeGen/WebAssembly/f64.ll index 1407f713b48..51eb33790a9 100644 --- a/llvm/test/CodeGen/WebAssembly/f64.ll +++ b/llvm/test/CodeGen/WebAssembly/f64.ll @@ -13,6 +13,7 @@ declare double @llvm.floor.f64(double) declare double @llvm.trunc.f64(double) declare double @llvm.nearbyint.f64(double) declare double @llvm.rint.f64(double) +declare double @llvm.fma.f64(double, double, double) ; CHECK-LABEL: fadd64: ; CHECK-NEXT: .param f64, f64{{$}} @@ -143,3 +144,11 @@ define double @fmax64(double %x) { %b = select i1 %a, double %x, double 0.0 ret double %b } + +; CHECK-LABEL: fma64: +; CHECK: call $push0=, fma, $0, $1, $2{{$}} +; CHECK-NEXT: return $pop0{{$}} +define double @fma64(double %a, double %b, double %c) { + %d = call double @llvm.fma.f64(double %a, double %b, double %c) + ret double %d +} |

