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

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 6 04:13:10 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Ralf Jung (RalfJung)

<details>
<summary>Changes</summary>

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

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


1 Files Affected:

- (modified) llvm/docs/LangRef.rst (+6-2) 


``````````diff
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:
 

``````````

</details>


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


More information about the llvm-commits mailing list