[llvm] 38ad926 - [LangRef] Clarify the behavior of select with FP poison-generating flags (#137131)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 24 22:47:12 PDT 2025


Author: Yingwei Zheng
Date: 2025-04-25T13:47:08+08:00
New Revision: 38ad9266b6705818544c03856eeef8335961dc22

URL: https://github.com/llvm/llvm-project/commit/38ad9266b6705818544c03856eeef8335961dc22
DIFF: https://github.com/llvm/llvm-project/commit/38ad9266b6705818544c03856eeef8335961dc22.diff

LOG: [LangRef] Clarify the behavior of select with FP poison-generating flags (#137131)

RFC link:
https://discourse.llvm.org/t/rfc-clarify-the-behavior-of-select-with-fp-poison-generating-flags/85974

Actually, it does not conflict with the definition of FMF if we
interpret a select as `applyFMF(select cond, applyFMF(TrueArm),
applyFMF(FalseArm))`.

Added: 
    

Modified: 
    llvm/docs/LangRef.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 9e78f317bd9ea..5bd1d29487139 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12880,7 +12880,10 @@ class <t_firstclass>` type.
    :ref:`fast-math flags <fastmath>`. These are optimization hints to enable
    otherwise unsafe floating-point optimizations. Fast-math flags are only valid
    for selects that return :ref:`supported floating-point types
-   <fastmath_return_types>`.
+   <fastmath_return_types>`. Note that the presence of value which would otherwise result
+   in poison does not cause the result to be poison if the value is on the non-selected arm.
+   If :ref:`fast-math flags <fastmath>` are present, they are only applied to the result,
+   not both arms.
 
 Semantics:
 """"""""""
@@ -12900,7 +12903,9 @@ Example:
 
 .. code-block:: llvm
 
-      %X = select i1 true, i8 17, i8 42          ; yields i8:17
+      %X = select i1 true, i8 17, i8 42                   ; yields i8:17
+      %Y = select nnan i1 true, float 0.0, float NaN      ; yields float:0.0
+      %Z = select nnan i1 false, float 0.0, float NaN     ; yields float:poison
 
 
 .. _i_freeze:


        


More information about the llvm-commits mailing list