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

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 09:50:13 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:

What do you intend by the "handles error conditions in the same way" part of this? The C documentation for rint is a bit ambiguous in that it indicates that the function "may" raise FE_INEXACT, but it doesn't require it or say what will be done about it. Near as I can tell, the function doesn't actually perform any erorr handling. It just allows the implementation to raise the exception.

The fact that we have both llvm.rint and llvm.nearbyint is a bit of a problem, I think. Since "the default LLVM floating-point environment assumes that traps are disabled and status flags are not observable" (per the language reference), there should be no difference at all between llvm.rint and llvm.nearbyint.

If we intend to forbid implementations of llvm.nearbyint from raising the FE_INEXACT exception, that should be explicitly documented. On the other hand, if we aren't requiring that, we should probably say that explicitly too.

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


More information about the llvm-commits mailing list