diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2023-07-21 15:33:09 -0400 |
|---|---|---|
| committer | Caleb Zulawski <caleb.zulawski@gmail.com> | 2023-07-21 15:33:09 -0400 |
| commit | 11c43c0c160539b6d040539b668e0142769537a5 (patch) | |
| tree | e2f65846463e5ecb442c1dbbd1515ef7b342a8b8 | |
| parent | 7c7dbe0c505ccbc02ff30c1e37381ab1d47bf46f (diff) | |
| download | rust-11c43c0c160539b6d040539b668e0142769537a5.tar.gz rust-11c43c0c160539b6d040539b668e0142769537a5.zip | |
Fix is_subnormal on architectures that flush subnormals to zero
| -rw-r--r-- | crates/core_simd/src/elements/float.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/core_simd/src/elements/float.rs b/crates/core_simd/src/elements/float.rs index 501c1c5ddd3..d700011ff9c 100644 --- a/crates/core_simd/src/elements/float.rs +++ b/crates/core_simd/src/elements/float.rs @@ -336,7 +336,10 @@ macro_rules! impl_trait { #[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] |
