diff options
Diffstat (limited to 'vendor/compiler_builtins/libm/src/math')
-rw-r--r-- | vendor/compiler_builtins/libm/src/math/erf.rs | 2 | ||||
-rw-r--r-- | vendor/compiler_builtins/libm/src/math/erff.rs | 2 | ||||
-rw-r--r-- | vendor/compiler_builtins/libm/src/math/fma.rs | 17 | ||||
-rw-r--r-- | vendor/compiler_builtins/libm/src/math/sqrt.rs | 16 | ||||
-rw-r--r-- | vendor/compiler_builtins/libm/src/math/sqrtf.rs | 16 |
5 files changed, 37 insertions, 16 deletions
diff --git a/vendor/compiler_builtins/libm/src/math/erf.rs b/vendor/compiler_builtins/libm/src/math/erf.rs index 5e21ba578..55569affc 100644 --- a/vendor/compiler_builtins/libm/src/math/erf.rs +++ b/vendor/compiler_builtins/libm/src/math/erf.rs @@ -263,7 +263,7 @@ pub fn erf(x: f64) -> f64 { } } -/// Error function (f64) +/// Complementary error function (f64) /// /// Calculates the complementary probability. /// Is `1 - erf(x)`. Is computed directly, so that you can use it to avoid diff --git a/vendor/compiler_builtins/libm/src/math/erff.rs b/vendor/compiler_builtins/libm/src/math/erff.rs index f74d4b632..7b25474f6 100644 --- a/vendor/compiler_builtins/libm/src/math/erff.rs +++ b/vendor/compiler_builtins/libm/src/math/erff.rs @@ -174,7 +174,7 @@ pub fn erff(x: f32) -> f32 { } } -/// Error function (f32) +/// Complementary error function (f32) /// /// Calculates the complementary probability. /// Is `1 - erf(x)`. Is computed directly, so that you can use it to avoid diff --git a/vendor/compiler_builtins/libm/src/math/fma.rs b/vendor/compiler_builtins/libm/src/math/fma.rs index f9a86dc60..940ee2db9 100644 --- a/vendor/compiler_builtins/libm/src/math/fma.rs +++ b/vendor/compiler_builtins/libm/src/math/fma.rs @@ -29,21 +29,10 @@ fn normalize(x: f64) -> Num { Num { m: ix, e, sign } } +#[inline] fn mul(x: u64, y: u64) -> (u64, u64) { - let t1: u64; - let t2: u64; - let t3: u64; - let xlo: u64 = x as u32 as u64; - let xhi: u64 = x >> 32; - let ylo: u64 = y as u32 as u64; - let yhi: u64 = y >> 32; - - t1 = xlo * ylo; - t2 = xlo * yhi + xhi * ylo; - t3 = xhi * yhi; - let lo = t1.wrapping_add(t2 << 32); - let hi = t3 + (t2 >> 32) + (t1 > lo) as u64; - (hi, lo) + let t = (x as u128).wrapping_mul(y as u128); + ((t >> 64) as u64, t as u64) } /// Floating multiply add (f64) diff --git a/vendor/compiler_builtins/libm/src/math/sqrt.rs b/vendor/compiler_builtins/libm/src/math/sqrt.rs index f06b209a4..3733ba040 100644 --- a/vendor/compiler_builtins/libm/src/math/sqrt.rs +++ b/vendor/compiler_builtins/libm/src/math/sqrt.rs @@ -261,4 +261,20 @@ mod tests { assert_eq!(sqrt(f), f); } } + + #[test] + fn conformance_tests() { + let values = [3.14159265359, 10000.0, f64::from_bits(0x0000000f), INFINITY]; + let results = [ + 4610661241675116657u64, + 4636737291354636288u64, + 2197470602079456986u64, + 9218868437227405312u64, + ]; + + for i in 0..values.len() { + let bits = f64::to_bits(sqrt(values[i])); + assert_eq!(results[i], bits); + } + } } diff --git a/vendor/compiler_builtins/libm/src/math/sqrtf.rs b/vendor/compiler_builtins/libm/src/math/sqrtf.rs index 00b20e578..8ec72fbf7 100644 --- a/vendor/compiler_builtins/libm/src/math/sqrtf.rs +++ b/vendor/compiler_builtins/libm/src/math/sqrtf.rs @@ -151,4 +151,20 @@ mod tests { assert_eq!(sqrtf(f), f); } } + + #[test] + fn conformance_tests() { + let values = [ + 3.14159265359f32, + 10000.0f32, + f32::from_bits(0x0000000f), + INFINITY, + ]; + let results = [1071833029u32, 1120403456u32, 456082799u32, 2139095040u32]; + + for i in 0..values.len() { + let bits = f32::to_bits(sqrtf(values[i])); + assert_eq!(results[i], bits); + } + } } |