-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Change rint to roundeven in round_ties_even implementation #136459
Copy link
Copy link
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
C has three reasonably similar ways to round a single float to even. I'll just copy the docs here,
nearbyint:rint:And
roundeven, which is available since C23:We currently use
rintf16,rintf32,rintf64, andrintf128(e.g. https://doc.rust-lang.org/std/intrinsics/fn.rintf32.html) as the intrinsics to implementround_ties_even. These map to LLVM'srintand similar:rust/compiler/rustc_codegen_llvm/src/intrinsic.rs
Lines 129 to 132 in 613bdd4
rintis not exactly what we want here because it is supposed to raise inexact. We should change toroundevenbecause it matches Rust's preference of ignoring rounding modes and never raising fp exceptions.This may be blocked on platform support, e.g. llvm/llvm-project#73588.that issue looks like it is about the vector version.Cc #55107.