[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
Wed Dec 3 00:03:07 PST 2025
https://github.com/RalfJung updated https://github.com/llvm/llvm-project/pull/170177
>From 34247f73c6b47ede412146d32741a2453bd466d2 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Mon, 1 Dec 2025 18:54:47 +0100
Subject: [PATCH] [LangRef] make consequences of NaN rules for pow(i) more
explicit
---
llvm/docs/LangRef.rst | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 02865f8a29c67..4524875b5f1b4 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -16269,6 +16269,12 @@ Semantics:
This function returns the first value raised to the second power with an
unspecified sequence of rounding operations.
+Note that the `powi` function is unusual in that NaN inputs can lead to non-NaN
+results, and this depends on the kind of NaN (quiet vs signaling). Due to how
+:ref:`LLVM treats NaN values <floatnan>`, the function may non-deterministically
+treat signaling NaNs as quiet NaNs. For example, `powi(QNaN, 0)` returns `1.0`,
+and `pow(SNaN, 0)` may non-deterministically return `1.0` or a NaN.
+
.. _t_llvm_sin:
'``llvm.sin.*``' Intrinsic
@@ -16831,6 +16837,12 @@ trapping or setting ``errno``.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
+Note that the `pow` function is unusual in that NaN inputs can lead to non-NaN
+results, and this depends on the kind of NaN (quiet vs signaling). Due to how
+:ref:`LLVM treats NaN values <floatnan>`, the function may non-deterministically
+treat signaling NaNs as quiet NaNs. For example, `pow(QNaN, 0.0)` returns `1.0`,
+and `pow(SNaN, 0.0)` may non-deterministically return `1.0` or a NaN.
+
.. _int_exp:
'``llvm.exp.*``' Intrinsic
More information about the llvm-commits
mailing list