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

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 6 04:12:35 PST 2024


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

According to [the docs](https://llvm.org/docs/LangRef.html#floating-point-environment), LLVM assumes round-to-nearest mode. The source code also contains some indications of LLVM constant-folding these intrinsics without regard for a possibly changed rounding mode:

https://github.com/llvm/llvm-project/blob/d08482924efe8b2c44913583af7b8f60a29975d1/llvm/lib/Analysis/ConstantFolding.cpp#L1615-L1624

https://github.com/llvm/llvm-project/blob/d08482924efe8b2c44913583af7b8f60a29975d1/llvm/lib/Analysis/ConstantFolding.cpp#L2097-L2100

>From 255b63efa92dcc81669cf6af5206eb905d649cd7 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Sat, 6 Jan 2024 13:06:04 +0100
Subject: [PATCH] LangRef: rint, nearbyint: mention that default rounding mode
 is assumed

---
 llvm/docs/LangRef.rst | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index b5918e3063d868..772620a3630b3e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -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
+is assumed to be set to "nearest", so halfway cases are rounded to the
+even integer.
 
 .. _int_nearbyint:
 
@@ -15789,7 +15791,9 @@ 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. The
+rounding mode is assumed to be set to "nearest", so halfway cases
+are rounded to the even integer.
 
 .. _int_round:
 



More information about the llvm-commits mailing list