Skip to content

Commit 136e5e2

Browse files
authored
[LangRef] make consequences of NaN rules for pow(i) more explicit (llvm#170177)
The NaN section says > Floating-point math operations are allowed to treat all NaNs as if they were quiet NaNs. For example, “pow(1.0, SNaN)” may be simplified to 1.0. This seems worth also spelling out in the section for `pow` (and `powi` which has a similar situation), to have everything concerning those operations in a single place.
1 parent 1d0d7da commit 136e5e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16289,6 +16289,13 @@ Semantics:
1628916289
This function returns the first value raised to the second power with an
1629016290
unspecified sequence of rounding operations.
1629116291

16292+
Note that the `powi` function is unusual in that NaN inputs can lead to non-NaN
16293+
results, and this depends on the kind of NaN (quiet vs signaling). Due to how
16294+
:ref:`LLVM treats NaN values <floatnan>` in non-constrained functions, the
16295+
function may non-deterministically treat signaling NaNs as quiet NaNs. For
16296+
example, `powi(QNaN, 0)` returns `1.0`, and `powi(SNaN, 0)` may
16297+
non-deterministically return `1.0` or a NaN.
16298+
1629216299
.. _t_llvm_sin:
1629316300

1629416301
'``llvm.sin.*``' Intrinsic
@@ -16851,6 +16858,13 @@ trapping or setting ``errno``.
1685116858
When specified with the fast-math-flag 'afn', the result may be approximated
1685216859
using a less accurate calculation.
1685316860

16861+
Note that the `pow` function is unusual in that NaN inputs can lead to non-NaN
16862+
results, and this depends on the kind of NaN (quiet vs signaling). Due to how
16863+
:ref:`LLVM treats NaN values <floatnan>` in non-constrained functions, the
16864+
function may non-deterministically treat signaling NaNs as quiet NaNs. For
16865+
example, `pow(QNaN, 0.0)` returns `1.0`, and `pow(SNaN, 0.0)` may
16866+
non-deterministically return `1.0` or a NaN.
16867+
1685416868
.. _int_exp:
1685516869

1685616870
'``llvm.exp.*``' Intrinsic

0 commit comments

Comments
 (0)