[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 15:06:40 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:

> I checked with the chair of the WG14 floating-point study group and received this response:
> 
> > Clause 7 is for all implementations, not just Annex F ones, so cannot require floating-point exceptions. See F.10.6.4. It’s implementation-defined behavior, but Annex F defines the behavior for implementations that support it.

That makes sense, but it takes it back to the question of the LLVM default environment. Since the default environment doesn't support exceptions, the llvm.rint intrinsic shouldn't have such a requirement and front ends that intend to support full exception semantics should use the constrained intrinsic (at least until we have a scheme that handles fp exceptions in a better way).

Anyone who relies on IEEE-753/IEC 60559 exception semantics with the default instructions and intrinsics is going to be disappointed sooner or later. You end up with something that might work sometimes, maybe even most of the time, but it won't be robust enough for critical work. (See, for example, https://github.com/llvm/llvm-project/issues/34581)

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


More information about the llvm-commits mailing list