Use force_eval instead of to_bits/from_bits combination,

Using to_bits/from_bits to force conversion to storage format
apparently doesn't work in release mode. Also add an architecture
conditional to avoid pessimising other architectures.
This commit is contained in:
Peter Michael Green 2021-12-21 22:41:29 +00:00
parent 17c9073298
commit 874209b56c

View file

@ -43,9 +43,11 @@ pub(crate) fn rem_pio2f(x: f32) -> (i32, f64) {
if ix < 0x4dc90fdb {
/* |x| ~< 2^28*(pi/2), medium size */
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
// use to_bits and from_bits to force rounding to storage format on
// x87.
let f_n = f64::from_bits((x64 * INV_PIO2 + TOINT).to_bits()) - TOINT;
let tmp = x64 * INV_PIO2 + TOINT;
// force rounding of tmp to it's storage format on x87 to avoid
// excess precision issues.
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(tmp);
let f_n = tmp - TOINT;
return (f_n as i32, x64 - f_n * PIO2_1 - f_n * PIO2_1T);
}
if ix >= 0x7f800000 {