Skip to content

Commit

Permalink
Use force_eval instead of to_bits/from_bits combination,
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Peter Michael Green committed Jan 4, 2022
1 parent 8b0db9f commit 16ce35b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/math/rem_pio2f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 16ce35b

Please sign in to comment.