Skip to content

Commit 11c43c0

Browse files
committed
Fix is_subnormal on architectures that flush subnormals to zero
1 parent 7c7dbe0 commit 11c43c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/core_simd/src/elements/float.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ macro_rules! impl_trait {
336336

337337
#[inline]
338338
fn is_subnormal(self) -> Self::Mask {
339-
self.abs().simd_ne(Self::splat(0.0)) & (self.to_bits() & Self::splat(Self::Scalar::INFINITY).to_bits()).simd_eq(Simd::splat(0))
339+
// On some architectures (e.g. armv7 and some ppc) subnormals are flushed to zero,
340+
// so this comparison must be done with integers.
341+
let not_zero = self.abs().to_bits().simd_ne(Self::splat(0.0).to_bits());
342+
not_zero & (self.to_bits() & Self::splat(Self::Scalar::INFINITY).to_bits()).simd_eq(Simd::splat(0))
340343
}
341344

342345
#[inline]

0 commit comments

Comments
 (0)