Skip to content

Commit 38ad926

Browse files
authored
[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))`.
1 parent 3b58a60 commit 38ad926

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/docs/LangRef.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12880,7 +12880,10 @@ class <t_firstclass>` type.
1288012880
:ref:`fast-math flags <fastmath>`. These are optimization hints to enable
1288112881
otherwise unsafe floating-point optimizations. Fast-math flags are only valid
1288212882
for selects that return :ref:`supported floating-point types
12883-
<fastmath_return_types>`.
12883+
<fastmath_return_types>`. Note that the presence of value which would otherwise result
12884+
in poison does not cause the result to be poison if the value is on the non-selected arm.
12885+
If :ref:`fast-math flags <fastmath>` are present, they are only applied to the result,
12886+
not both arms.
1288412887

1288512888
Semantics:
1288612889
""""""""""
@@ -12900,7 +12903,9 @@ Example:
1290012903

1290112904
.. code-block:: llvm
1290212905

12903-
%X = select i1 true, i8 17, i8 42 ; yields i8:17
12906+
%X = select i1 true, i8 17, i8 42 ; yields i8:17
12907+
%Y = select nnan i1 true, float 0.0, float NaN ; yields float:0.0
12908+
%Z = select nnan i1 false, float 0.0, float NaN ; yields float:poison
1290412909

1290512910

1290612911
.. _i_freeze:

0 commit comments

Comments
 (0)