[llvm] LangRef: rint, nearbyint: mention that default rounding mode is assumed (PR #77191)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 11:07:50 PST 2024


================
@@ -15751,7 +15751,9 @@ 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. The rounding mode
----------------
andykaylor wrote:

> Where the standard says "may rise", LLVM decides to implement this as "will never rise". That's a valid implementation.

Strictly speaking, LLVM implements it as "pretend it will never raise..." The exception flags are generally implemented in hardware and in practice some lowerings of llvm.rint will raise the exception. For example, if the target is x86-64, we will use the ROUNDSD instruction, which has an operand that controls whether or not the exception is raised. As it happens, we choose to let the exception be raised for rint, but we suppress it for nearbyint.

https://godbolt.org/z/sanTWxKoc

https://github.com/llvm/llvm-project/pull/77191


More information about the llvm-commits mailing list