[llvm] APFloat: Add minimumnum and maximumnum (PR #96304)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 07:32:33 PDT 2024
================
@@ -1483,6 +1483,19 @@ inline APFloat minimum(const APFloat &A, const APFloat &B) {
return B < A ? B : A;
}
+/// Implements IEEE 754-2019 minimumNumber semantics. Returns the smaller
+/// of 2 arguments, not propagating NaNs and treating -0 as less than +0.
+LLVM_READONLY
+inline APFloat minimumnum(const APFloat &A, const APFloat &B) {
+ if (A.isNaN())
+ return B.isNaN() ? B.makeQuiet() : B;
+ if (B.isNaN())
----------------
wzssyqa wrote:
Maybe I don't understand your question well.
If you mean about is the result correct if either/both of A or/and B is/are sNaN, I think that it can give correct result.
When we in `if (B.isNaN())`, we are sure that `A` is not NaN.
If you are talking about exception handling, in fact I am not sure. I just noticed that `minnum`/`minimum` don't do
very special work for exception handling.
https://github.com/llvm/llvm-project/pull/96304
More information about the llvm-commits
mailing list