Skip to content

Commit 241e894

Browse files
committed
Apply suggestions:
Reuse llvm's nan def no more undef target-specific statement
1 parent 655b487 commit 241e894

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

llvm/docs/LangRef.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21587,7 +21587,7 @@ Arguments:
2158721587

2158821588
``rounding mode``
2158921589
A metadata string specifying the rounding mode. The permitted strings match those
21590-
accepted by :ref:`llvm.fptrunc.round <int_fptrunc_round>` (for example,
21590+
accepted by ``llvm.fptrunc.round`` (for example,
2159121591
``"round.tonearest"`` or ``"round.towardzero"``).
2159221592

2159321593
The rounding mode is only consulted when ``value`` is not exactly representable in the target format.
@@ -21618,25 +21618,23 @@ integer (e.g., ``i8`` for FP8, ``i6`` for FP6) containing the encoded arbitrary
2161821618

2161921619
**Handling of special values:**
2162021620

21621-
- **NaN**: If the input is NaN and the target format supports NaN, it is converted to a NaN
21622-
representation in the target format. The exact NaN payload and quiet/signaling status are
21623-
implementation-defined; implementations may preserve them when the target supports it.
21624-
If the target format does not support NaN, the intrinsic returns a poison value.
21625-
- **Infinity**: If the input is +/-Inf:
21621+
- **NaN**: NaN values follow LLVM's standard :ref:`NaN rules <floatnan>`. When the target
21622+
format supports NaN, the NaN representation is preserved (quiet NaNs remain quiet, signaling
21623+
NaNs remain signaling). The exact NaN payload may be truncated or extended to fit the target
21624+
format's payload size. If the target format does not support NaN, the intrinsic returns a
21625+
poison value.
21626+
- **Infinity and Overflow**: If the input is +/-Inf or a finite value that exceeds the representable range:
2162621627

21627-
- When ``saturation`` is ``false`` and the target format supports infinity, +/-Inf is preserved.
21628+
- When ``saturation`` is ``false`` and the target format supports infinity, the result is +/-Inf (preserving the sign).
2162821629
- When ``saturation`` is ``false`` and the target format does not support infinity (e.g., formats
2162921630
with "FN" suffix), the intrinsic returns a poison value.
21630-
- When ``saturation`` is ``true``, +/-Inf is clamped to the maximum/minimum representable finite value.
21631+
- When ``saturation`` is ``true``, the value is clamped to the maximum/minimum representable finite value.
2163121632

21632-
- **Overflow**: When a finite value exceeds the representable range:
21633+
For FP6/FP4 interpretations, producers are expected to use ``saturation`` = ``true``; using ``saturation`` = ``false`` and generating NaN/Inf/overflowing values results in a poison value.
2163321634

21634-
- When ``saturation`` is ``true``, the value is clamped to the maximum/minimum representable finite value.
21635-
- When ``saturation`` is ``false`` and the target format supports infinity, the value becomes +/-Inf.
21636-
- When ``saturation`` is ``false`` and the target format does not support infinity, the intrinsic
21637-
returns a poison value.
21635+
.. note::
2163821636

21639-
For FP6/FP4 interpretations, producers are expected to use ``saturation`` = ``true``; using ``saturation`` = ``false`` and generating NaN/Inf/overflowing values is undefined (poison).
21637+
The supported conversions are target dependent.
2164021638

2164121639
Example:
2164221640
""""""""
@@ -21694,12 +21692,16 @@ The intrinsic interprets the integer value as arbitrary FP bits according to
2169421692

2169521693
Conversions from arbitrary FP formats to native LLVM floating-point types are typically
2169621694
widening conversions (e.g., FP8 to FP16 or FP32), which are exact and require no rounding.
21697-
Normal finite values are converted exactly. NaN values in the source format are converted to
21698-
NaN in the target format. The exact NaN payload and quiet/signaling status are
21699-
implementation-defined; implementations may preserve them when the target supports it.
21700-
Infinity values are preserved as infinity. If a value exceeds the representable range of the
21701-
target type (for example, converting ``Float8E8M0FNU`` with large exponents to ``half``),
21702-
the result is converted to infinity with the appropriate sign.
21695+
Normal finite values are converted exactly. NaN values follow LLVM's standard :ref:`NaN rules
21696+
<floatnan>`; the NaN representation is preserved (quiet NaNs remain quiet, signaling NaNs
21697+
remain signaling), and the NaN payload may be truncated or extended to fit the target format's
21698+
payload size. Infinity values are preserved as infinity. If a value exceeds the representable
21699+
range of the target type (for example, converting ``Float8E8M0FNU`` with large exponents to
21700+
``half``), the result is converted to infinity with the appropriate sign.
21701+
21702+
.. note::
21703+
21704+
The supported conversions are target dependent.
2170321705

2170421706
Example:
2170521707
""""""""

0 commit comments

Comments
 (0)