rust/library
Matthias Krüger 789d168e13
Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm
Adds IEEE 754-2019 minimun and maximum functions for f32/f64

IEEE 754-2019 removed the `minNum` (`min` in Rust) and `maxNum` (`max` in Rust) operations in favor of the newly created `minimum` and `maximum` operations due to their [non-associativity](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf) that cannot be fix in a backwards compatible manner. This PR adds `fN::{minimun,maximum}` functions following the new rules.

### IEEE 754-2019 Rules

> **minimum(x, y)** is x if x < y, y if y < x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, −0 compares less than +0. Otherwise (i.e., when x = y and signs are the same)
it is either x or y.

> **maximum(x, y)** is x if x > y, y if y > x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, +0 compares greater than −0. Otherwise (i.e., when x = y and signs are the
same) it is either x or y.

"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` ](90f0ac10a7/math/s_fminimum_template.c) (it self derived from the C2X draft) expect that:
 - it doesn't use `copysign` because it's not available in `core` and also because `copysign` is unnecessary (we only want to check the sign, no need to create a new float)
 - it also prefer `other > self` instead of `self < other` like IEEE 754-2019 does

I originally tried to implement them [using intrinsics](1d8aa13bc3) but LLVM [error out](https://godbolt.org/z/7sMrxW49a) 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 https://github.com/rust-lang/rust/issues/83984
2021-11-21 09:55:13 +01:00
..
alloc Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum 2021-11-20 22:33:48 +01:00
backtrace@b02ed04a7e Updated backtrace submodule 2021-11-02 12:31:34 +01:00
core Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm 2021-11-21 09:55:13 +01:00
panic_abort Use target_family = "wasm" 2021-11-10 08:35:42 -08:00
panic_unwind Review comments 2021-11-10 08:35:42 -08:00
portable-simd Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99' 2021-11-12 16:58:25 -08:00
proc_macro proc_macro: Add an expand_expr method to TokenStream 2021-11-12 15:41:40 -05:00
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm 2021-11-21 09:55:13 +01:00
stdarch@cfba59fccd Update stdarch 2021-11-19 11:20:42 -08:00
test Update more rustc/libtest things for wasm64 2021-11-10 08:35:42 -08:00
unwind