You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: llvm/docs/LangRef.rst
+22-20Lines changed: 22 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21587,7 +21587,7 @@ Arguments:
21587
21587
21588
21588
``rounding mode``
21589
21589
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,
21591
21591
``"round.tonearest"`` or ``"round.towardzero"``).
21592
21592
21593
21593
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
21618
21618
21619
21619
**Handling of special values:**
21620
21620
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:
21626
21627
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).
21628
21629
- When ``saturation`` is ``false`` and the target format does not support infinity (e.g., formats
21629
21630
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.
21631
21632
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.
21633
21634
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::
21638
21636
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.
21640
21638
21641
21639
Example:
21642
21640
""""""""
@@ -21694,12 +21692,16 @@ The intrinsic interprets the integer value as arbitrary FP bits according to
21694
21692
21695
21693
Conversions from arbitrary FP formats to native LLVM floating-point types are typically
21696
21694
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.
0 commit comments