-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds IEEE 754-2019 minimun and maximum functions for f32/f64 #91008
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to offer to me -- it's clearly useful, and llvm having an intrinsic for it is extra evidence that it makes sense in core
, even if it's not implemented yet. I'm not on libs-api, but I'd be fine putting this in as unstable.
Can you open a tracking issue for this and add the number to the stability attributes?
1645950
to
2bad893
Compare
👍 Thanks.
Done. I also squash some of the commits. |
Co-authored-by: est31 <est31@users.noreply.github.com>
📌 Commit e2ec3b1 has been approved by |
…askrgr Rollup of 4 pull requests Successful merges: - rust-lang#91008 (Adds IEEE 754-2019 minimun and maximum functions for f32/f64) - rust-lang#91070 (Make `LLVMRustGetOrInsertGlobal` always return a `GlobalVariable`) - rust-lang#91097 (Add spaces in opaque `impl Trait` with more than one trait) - rust-lang#91098 (Don't suggest certain fixups (`.field`, `.await`, etc) when reporting errors while matching on arrays ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
IEEE 754-2019 removed the
minNum
(min
in Rust) andmaxNum
(max
in Rust) operations in favor of the newly createdminimum
andmaximum
operations due to their non-associativity that cannot be fix in a backwards compatible manner. This PR addsfN::{minimun,maximum}
functions following the new rules.IEEE 754-2019 Rules
"IEEE Standard for Floating-Point Arithmetic," in IEEE Std 754-2019 (Revision of IEEE 754-2008) , vol., no., pp.1-84, 22 July 2019, doi: 10.1109/IEEESTD.2019.8766229.
Implementation
This implementation is inspired by the one in
glibc
(it self derived from the C2X draft) expect that:copysign
because it's not available incore
and also becausecopysign
is unnecessary (we only want to check the sign, no need to create a new float)other > self
instead ofself < other
like IEEE 754-2019 doesI originally tried to implement them using intrinsics but LLVM error out when trying to lower them to machine intructions, GCC doesn't yet have built-ins for them, only cranelift support them nativelly (as it doesn't support the nativelly the old sementics).
Helps with #83984