[llvm] [LangRef] make consequences of NaN rules for pow(i) more explicit (PR #170177)

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 13:26:15 PST 2025


================
@@ -16831,6 +16836,11 @@ trapping or setting ``errno``.
 When specified with the fast-math-flag 'afn', the result may be approximated
 using a less accurate calculation.
 
+Note that due to how :ref:`LLVM treats NaN values <floatnan>`, the special cases
----------------
RalfJung wrote:

@efriedma-quic 
> That said, maybe we should go into less detail here to avoid explaining the rules in multiple places. Just say "note this operation can return a non-NaN result given an SNaN input; see https://llvm.org/docs/LangRef.html#behavior-of-floating-point-nan-values for details".

I'm open to making this shorter, but I think we should be very explicit about this being non-determinism, to avoid any doubt about what "can return" means. It's not just some backend choice or so. It means that we can call the same function with the same inputs twice and get different results (depending on whether LLVM can const-propagate everything or whether a libcall is used).

https://github.com/llvm/llvm-project/pull/170177


More information about the llvm-commits mailing list