diff options
| author | Trevor Gross <tmgross@umich.edu> | 2025-05-28 21:08:41 +0000 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-05-28 21:10:28 +0000 |
| commit | 5978b8b875f6c53af9ca4c72f4ea5fcf74d55c84 (patch) | |
| tree | b305e39ce1794f31342631cb9928a0c2c8bec994 | |
| parent | c04f133858c3208525ae8fe47057fb157c18d606 (diff) | |
| download | rust-5978b8b875f6c53af9ca4c72f4ea5fcf74d55c84.tar.gz rust-5978b8b875f6c53af9ca4c72f4ea5fcf74d55c84.zip | |
aarch64: Add a note saying why we use `frintx` rather than `frintn`
| -rw-r--r-- | library/compiler-builtins/libm/src/math/arch/aarch64.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/compiler-builtins/libm/src/math/arch/aarch64.rs b/library/compiler-builtins/libm/src/math/arch/aarch64.rs index 020bb731cdc..8896804b504 100644 --- a/library/compiler-builtins/libm/src/math/arch/aarch64.rs +++ b/library/compiler-builtins/libm/src/math/arch/aarch64.rs @@ -30,6 +30,12 @@ pub fn fmaf(mut x: f32, y: f32, z: f32) -> f32 { x } +// NB: `frintx` is technically the correct instruction for C's `rint`. However, in Rust (and LLVM +// by default), `rint` is identical to `roundeven` (no fpenv interaction) so we use the +// side-effect-free `frintn`. +// +// In general, C code that calls Rust's libm should assume that fpenv is ignored. + pub fn rint(mut x: f64) -> f64 { // SAFETY: `frintn` is available with neon and has no side effects. // |
