Skip to content

Commit

Permalink
LangRef: rint, nearbyint: mention that default rounding mode is assum…
Browse files Browse the repository at this point in the history
…ed (#77191)

LLVM assumes round-to-nearest mode and sometimes performs constant-folding based on that assumption. This updates the language ref documentation for the rint and nearbyint intrinsics to mention that fact.
  • Loading branch information
RalfJung authored Jan 9, 2024
1 parent 47605ff commit fb14662
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15754,7 +15754,11 @@ Semantics:
""""""""""

This function returns the same values as the libm ``rint`` functions
would, and handles error conditions in the same way.
would, and handles error conditions in the same way. Since LLVM assumes the
:ref:`default floating-point environment <floatenv>`, the rounding mode is
assumed to be set to "nearest", so halfway cases are rounded to the even
integer. Use :ref:`Constrained Floating-Point Intrinsics <constrainedfp>`
to avoid that assumption.

.. _int_nearbyint:

Expand Down Expand Up @@ -15792,7 +15796,11 @@ Semantics:
""""""""""

This function returns the same values as the libm ``nearbyint``
functions would, and handles error conditions in the same way.
functions would, and handles error conditions in the same way. Since LLVM
assumes the :ref:`default floating-point environment <floatenv>`, the rounding
mode is assumed to be set to "nearest", so halfway cases are rounded to the even
integer. Use :ref:`Constrained Floating-Point Intrinsics <constrainedfp>` to
avoid that assumption.

.. _int_round:

Expand Down

0 comments on commit fb14662

Please sign in to comment.