summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2015-11-10 21:40:21 +0000
committerDan Gohman <dan433584@gmail.com>2015-11-10 21:40:21 +0000
commitb84ae9bb38dd5d5472d28b2c8f2b686ef1249a85 (patch)
tree2c01cc18bb01cb86abb09512108824c3d276c199 /llvm/lib
parent3809ca9d00eb8596d85b6ca7cdd32195c560cefb (diff)
downloadbcm5719-llvm-b84ae9bb38dd5d5472d28b2c8f2b686ef1249a85.tar.gz
bcm5719-llvm-b84ae9bb38dd5d5472d28b2c8f2b686ef1249a85.zip
[WebAssembly] Support for floating point min and max.
llvm-svn: 252653
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp3
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td10
2 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index baf5b2554bb..d813367ea85 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -132,6 +132,9 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
for (auto Op : {ISD::FCEIL, ISD::FFLOOR, ISD::FTRUNC, ISD::FNEARBYINT,
ISD::FRINT})
setOperationAction(Op, T, Legal);
+ // Support minnan and maxnan, which otherwise default to expand.
+ setOperationAction(ISD::FMINNAN, T, Legal);
+ setOperationAction(ISD::FMAXNAN, T, Legal);
}
for (auto T : {MVT::i32, MVT::i64}) {
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td
index 689aeac6291..232af03464a 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td
@@ -22,6 +22,9 @@ defm ABS : UnaryFP<fabs, "abs">;
defm NEG : UnaryFP<fneg, "neg">;
defm COPYSIGN : BinaryFP<fcopysign, "copysign">;
+defm MIN : BinaryFP<fminnan, "min">;
+defm MAX : BinaryFP<fmaxnan, "max">;
+
defm CEIL : UnaryFP<fceil, "ceil">;
defm FLOOR : UnaryFP<ffloor, "floor">;
defm TRUNC : UnaryFP<ftrunc, "trunc">;
@@ -52,13 +55,6 @@ def : Pat<(setle f64:$lhs, f64:$rhs), (LE_F64 f64:$lhs, f64:$rhs)>;
def : Pat<(setgt f64:$lhs, f64:$rhs), (GT_F64 f64:$lhs, f64:$rhs)>;
def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>;
-/*
- * TODO(jfb): Add the following for 32-bit and 64-bit.
- *
- * f32.min: minimum (binary operator); if either operand is NaN, returns NaN
- * f32.max: maximum (binary operator); if either operand is NaN, returns NaN
- */
-
def SELECT_F32 : I<(outs F32:$dst), (ins I32:$cond, F32:$lhs, F32:$rhs),
[(set F32:$dst, (select I32:$cond, F32:$lhs, F32:$rhs))],
"f32.select $dst, $cond, $lhs, $rhs">;
OpenPOWER on IntegriCloud