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

Joshua Cranmer via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 13:35:09 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
----------------
jcranmer-intel wrote:

IEEE 754-2019 has the general catch-all rule for operations in section 9.2 (which include `pow` and `powi`, assuming `powi` maps to IEEE 754 `pown`)
> An operation that returns a floating-point result shall return a quiet NaN as a result if there is a signaling NaN among the operation’s operands. An operation that returns a floating-point result shall return a quiet NaN as a result if there is a quiet NaN among the operation’s operands, except in the cases stated otherwise in this subclause.

glibc gives `pow(1, snan)` as `nan` and `pow(snan, 0)` as `nan` (see https://godbolt.org/z/KMrzMzKMo).

The other non-NaN-propagating functions are `hypot` (`hypot(1, nan) == 1`) and `compound`, neither of which are an LLVM intrinsic.

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


More information about the llvm-commits mailing list