[PATCH] D143074: [LangRef] improve documentation of SNaN in the default FP environment

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 07:41:07 PST 2023


spatel created this revision.
spatel added reviewers: efriedma, nlopes, arsenm, samparker, kpn, jyknight, sepavloff, jcranmer.
Herald added subscribers: StephenFan, jdoerfert, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Make it explicit that SNaN is not handled differently than QNaN in the LLVM default floating-point environment.

Note that an IEEE-754-compliant model disallows transforms like "X * 1.0 -> X". That is because math operations are expected to convert SNaN to QNaN (set the signaling bit).

But LLVM has had those kinds of transforms from the beginning:
https://alive2.llvm.org/ce/z/igb55y

We should be IEEE-754-compliant under strict-FP (the logic is implemented with a helper named `canIgnoreSNaN()`), but I don't think there is any demand to do that with default optimization.

See issue #43070 <https://github.com/llvm/llvm-project/issues/43070> for earlier draft/discussion about this change.


https://reviews.llvm.org/D143074

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -3284,8 +3284,9 @@
 The default LLVM floating-point environment assumes that floating-point
 instructions do not have side effects. Results assume the round-to-nearest
 rounding mode. No floating-point exception state is maintained in this
-environment. Therefore, there is no attempt to create or preserve invalid
-operation (SNaN) or division-by-zero exceptions.
+environment. Therefore, there is no attempt to create, clear, or preserve
+exceptions. The signaling bit of NaN values is undefined, so it may not
+be set as specified by IEEE-754.
 
 The benefit of this exception-free assumption is that floating-point
 operations may be speculated freely without any other fast-math relaxations


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143074.493935.patch
Type: text/x-patch
Size: 848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230201/c9d9453a/attachment.bin>


More information about the llvm-commits mailing list