Fix is_subnormal on architectures that flush subnormals to zero

This commit is contained in:
Caleb Zulawski 2023-07-21 15:33:09 -04:00
parent 7c7dbe0c50
commit 11c43c0c16

View File

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