summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/IRBuilderTest.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2018-10-13 07:21:44 +0000
committerThomas Lively <tlively@google.com>2018-10-13 07:21:44 +0000
commit16c349d892d4e2870c8bf73f943e37310a0d45ff (patch)
treea3b17f77a79102e265d226159eee584adbfd9e02 /llvm/unittests/IR/IRBuilderTest.cpp
parent0ff82ac154560a0bb2f30f97484fb41aeb4cc884 (diff)
downloadbcm5719-llvm-16c349d892d4e2870c8bf73f943e37310a0d45ff.tar.gz
bcm5719-llvm-16c349d892d4e2870c8bf73f943e37310a0d45ff.zip
[Intrinsic] Add llvm.minimum and llvm.maximum instrinsic functions
Summary: These new intrinsics have the semantics of the `minimum` and `maximum` operations specified by the latest draft of IEEE 754-2018. Unlike llvm.minnum and llvm.maxnum, these new intrinsics propagate NaNs and always treat -0.0 as less than 0.0. `minimum` and `maximum` lower directly to the existing `fminnan` and `fmaxnan` ISel DAG nodes. It is safe to reuse these DAG nodes because before this patch were only emitted in situations where there were known to be no NaN arguments or where NaN propagation was correct and there were known to be no zero arguments. I know of only four backends that lower fminnan and fmaxnan: WebAssembly, ARM, AArch64, and SystemZ, and each of these lowers fminnan and fmaxnan to instructions that are compatible with the IEEE 754-2018 semantics. Reviewers: aheejin, dschuff, sunfish, javed.absar Subscribers: kristof.beyls, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D52764 llvm-svn: 344437
Diffstat (limited to 'llvm/unittests/IR/IRBuilderTest.cpp')
-rw-r--r--llvm/unittests/IR/IRBuilderTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index 42c0393d382..713c0a14f66 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -68,6 +68,14 @@ TEST_F(IRBuilderTest, Intrinsics) {
II = cast<IntrinsicInst>(Call);
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maxnum);
+ Call = Builder.CreateMinimum(V, V);
+ II = cast<IntrinsicInst>(Call);
+ EXPECT_EQ(II->getIntrinsicID(), Intrinsic::minimum);
+
+ Call = Builder.CreateMaximum(V, V);
+ II = cast<IntrinsicInst>(Call);
+ EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maximum);
+
Call = Builder.CreateIntrinsic(Intrinsic::readcyclecounter, {}, {});
II = cast<IntrinsicInst>(Call);
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::readcyclecounter);
OpenPOWER on IntegriCloud