[llvm] LangRef: Clarify llvm.minnum and llvm.maxnum about sNaN and signed zero (PR #112852)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 22:52:22 PST 2025
================
@@ -16774,20 +16782,29 @@ type.
Semantics:
""""""""""
-Follows the IEEE-754 semantics for maxNum except for the handling of
-signaling NaNs. This matches the behavior of libm's fmax.
+Follows the semantics of maximumNumber in IEEE-754-2019, except for signaling NaNs. If either operand
+is an sNaN, the result is always a qNaN. This matches the recommended behavior for the libm
+function ``fmax``, although not all implementations have implemented these recommended behaviors.
+
+If either operand is a qNaN, returns the other non-NaN operand. Returns NaN only if both operands are
+NaN or if either operand is sNaN. Note that arithmetic on an sNaN doesn't consistently produce a qNaN,
+so arithmetic feeding into a maxnum can produce inconsistent results. For example,
+`maxnum(fadd(sNaN, 0.0), 1.0)` can produce qNaN or 1.0 depending on whether `fadd` is folded.
----------------
arsenm wrote:
```suggestion
`maxnum(fadd(sNaN, -0.0), 1.0)` can produce qNaN or 1.0 depending on whether `fadd` is folded.
```
https://github.com/llvm/llvm-project/pull/112852
More information about the llvm-commits
mailing list