Skip to content

Commit fc34c3e

Browse files
committed
aarch64: Add a note saying why we use frintx rather than frintn
1 parent 347adad commit fc34c3e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libm/src/math/arch/aarch64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ pub fn fmaf(mut x: f32, y: f32, z: f32) -> f32 {
3030
x
3131
}
3232

33+
// NB: `frintx` is technically the correct instruction for C's `rint`. However, in Rust (and LLVM
34+
// by default), `rint` is identical to `roundeven` (no fpenv interaction) so we use the
35+
// side-effect-free `frintn`.
36+
//
37+
// In general, C code that calls Rust's libm should assume that fpenv is ignored.
38+
3339
pub fn rint(mut x: f64) -> f64 {
3440
// SAFETY: `frintn` is available with neon and has no side effects.
3541
//

0 commit comments

Comments
 (0)