Skip to content

Commit 8d3d616

Browse files
committed
Apply review feedback
1 parent 541369c commit 8d3d616

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

crates/core_simd/src/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ macro_rules! impl_float_vector {
295295
#[inline]
296296
pub fn abs(self) -> Self {
297297
let no_sign = <$bits_ty>::splat(!0 >> 1);
298-
let abs = unsafe { crate::intrinsics::simd_and(self.to_bits(), no_sign) };
299-
Self::from_bits(abs)
298+
Self::from_bits(self.to_bits() & no_sign)
300299
}
301300
}
302301
};

crates/core_simd/tests/ops_impl/float_macros.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ macro_rules! float_tests {
1919
value
2020
}
2121

22+
fn slice_chunks(slice: &[$scalar]) -> impl Iterator<Item = core_simd::$vector> + '_ {
23+
let lanes = core::mem::size_of::<core_simd::$vector>() / core::mem::size_of::<$scalar>();
24+
slice.chunks_exact(lanes).map(from_slice)
25+
}
26+
2227
const A: [$scalar; 16] = [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.];
2328
const B: [$scalar; 16] = [16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31.];
2429
const C: [$scalar; 16] = [
@@ -303,9 +308,10 @@ macro_rules! float_tests {
303308
#[test]
304309
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
305310
fn abs_odd_floats() {
306-
let v = from_slice(&C);
307-
let expected = apply_unary_lanewise(v, <$scalar>::abs);
308-
assert_biteq!(v.abs(), expected);
311+
for v in slice_chunks(&C) {
312+
let expected = apply_unary_lanewise(v, <$scalar>::abs);
313+
assert_biteq!(v.abs(), expected);
314+
}
309315
}
310316
}
311317
}

0 commit comments

Comments
 (0)