Skip to content

Commit b1253db

Browse files
committed
fix bug in mul impl for simd
1 parent 670e832 commit b1253db

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/simd.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ where
205205
/// let sqrt = f.sqrt();
206206
///
207207
/// assert!((sqrt - SimdF64::<8>::splat(F64::from(9))).abs().simd_le(Simd::splat(1e-15)).all()); // this won't always be true for perfect squares, but in this case it is
208-
/// // FIXME:
209-
/// // assert!((sqrt * sqrt - f).abs().simd_le(Simd::splat(1e-7)).all());
208+
/// assert!((sqrt * sqrt - f).abs().simd_le(Simd::splat(1e-7)).all());
210209
/// ```
211210
#[inline]
212211
pub fn sqrt(self) -> Self {
@@ -242,8 +241,7 @@ where
242241
/// let f = SimdF64::<8>::splat(F64::from(13));
243242
/// let recip = f.recip();
244243
///
245-
/// // FIXME:
246-
/// // assert!((f * recip - SimdF64::<8>::splat(F64::ONE)).abs().simd_le(Simd::splat(1e-15)).all());
244+
/// assert!((f * recip - SimdF64::<8>::splat(F64::ONE)).abs().simd_le(Simd::splat(1e-15)).all());
247245
/// ```
248246
#[inline]
249247
pub fn recip(self) -> Self {
@@ -360,8 +358,7 @@ where
360358
/// let x = SimdF64::<8>::splat(F64::from(14));
361359
/// let y = SimdF64::<8>::splat(F64::from(6));
362360
///
363-
/// // FIXME:
364-
/// // assert!((x * y - SimdF64::<8>::splat(F64::from(84))).abs().simd_le(Simd::splat(1e-15)).all());
361+
/// assert!((x * y - SimdF64::<8>::splat(F64::from(84))).abs().simd_le(Simd::splat(1e-15)).all());
365362
/// ```
366363
#[inline]
367364
fn mul(self, rhs: Self) -> Self::Output {
@@ -381,7 +378,7 @@ where
381378
Simd::splat(0),
382379
);
383380
let mut s2 = (s0 * s1) & Simd::splat(F64::MASK_SIGNIFICAND);
384-
s2 = (self.is_nan() | rhs.is_nan()).select(s2, Simd::splat(0));
381+
s2 |= (self.is_nan() | rhs.is_nan()).select(Simd::splat(1), Simd::splat(0));
385382

386383
Self(e2 << Simd::splat(53) | s2)
387384
}
@@ -454,8 +451,7 @@ where
454451
///
455452
/// let x = SimdF64::<8>::splat(F64::from(18));
456453
/// let y = SimdF64::<8>::splat(F64::from(6));
457-
/// // FIXME:
458-
/// // assert!((x / y - SimdF64::<8>::splat(F64::from(3))).abs().simd_le(Simd::splat(1e-15)).all());
454+
/// assert!((x / y - SimdF64::<8>::splat(F64::from(3))).abs().simd_le(Simd::splat(1e-15)).all());
459455
/// ```
460456
#[inline]
461457
#[allow(clippy::suspicious_arithmetic_impl)] // lol

0 commit comments

Comments
 (0)