Skip to content

Commit 5523a31

Browse files
Merge #438: Use -0.0 as the neutral additive float
-0.0 + 0.0 is 0.0 -0.0 + -0.0 is -0.0 Thus, the float additive-zero is -0.0, not its positive cousin. This aligns with a recent change to the impl of Sum for floats, in rust-lang/rust@4908188
2 parents 7e162d1 + c080ba5 commit 5523a31

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

crates/core_simd/src/simd/num/float.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ macro_rules! impl_trait {
419419
self.as_array().iter().sum()
420420
} else {
421421
// Safety: `self` is a float vector
422-
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, 0.) }
422+
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, -0.) }
423423
}
424424
}
425425

crates/core_simd/tests/ops_macros.rs

+6
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ macro_rules! impl_float_tests {
527527
}
528528

529529
fn is_normal<const LANES: usize>() {
530+
// Arm v7 Neon violates float opsem re: subnormals, see
531+
// https://github.com/rust-lang/portable-simd/issues/439
532+
#[cfg(not(target_arch = "arm"))]
530533
test_helpers::test_unary_mask_elementwise(
531534
&Vector::<LANES>::is_normal,
532535
&Scalar::is_normal,
@@ -535,6 +538,9 @@ macro_rules! impl_float_tests {
535538
}
536539

537540
fn is_subnormal<const LANES: usize>() {
541+
// Arm v7 Neon violates float opsem re: subnormals, see
542+
// https://github.com/rust-lang/portable-simd/issues/439
543+
#[cfg(not(target_arch = "arm"))]
538544
test_helpers::test_unary_mask_elementwise(
539545
&Vector::<LANES>::is_subnormal,
540546
&Scalar::is_subnormal,

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-06-13"
2+
channel = "nightly-2024-09-11"
33
components = ["rustfmt", "clippy", "miri", "rust-src"]

0 commit comments

Comments
 (0)