From d5f918b96b36e483c164a71113e236278cda6fb3 Mon Sep 17 00:00:00 2001 From: Tobias Decking Date: Thu, 16 Feb 2023 18:22:17 +0100 Subject: [PATCH] Small tweak to `mul` in `fma.rs`. --- src/math/fma.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/math/fma.rs b/src/math/fma.rs index f9a86dc..940ee2d 100644 --- a/src/math/fma.rs +++ b/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)