Havok: Simplify hkSimdFloat32::sqrt/sqrtInverse

This commit is contained in:
Léo Lam 2022-01-28 14:12:13 +01:00
parent a3bf47bd9d
commit 0ef08bde7e
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
1 changed files with 4 additions and 4 deletions

View File

@ -222,10 +222,10 @@ inline hkSimdFloat32 hkSimdFloat32::reciprocal() const {
inline hkSimdFloat32 hkSimdFloat32::sqrt() const { inline hkSimdFloat32 hkSimdFloat32::sqrt() const {
#ifdef HK_SIMD_FLOAT32_AARCH64_NEON #ifdef HK_SIMD_FLOAT32_AARCH64_NEON
const auto equalsZero = vcle_f32(m_real, vcreate_f32(0)); const auto leqZero = vclez_f32(m_real);
const auto inv = sqrtInverseUnsafe().m_real; const auto inv = sqrtInverseUnsafe().m_real;
const auto r = m_real * inv; const auto r = m_real * inv;
return vbic_u32(r, equalsZero); return vbic_u32(r, leqZero);
#else #else
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
m_real[i] = m_real[i] >= 0.0f ? std::sqrt(m_real[i]) : 0.0f; m_real[i] = m_real[i] >= 0.0f ? std::sqrt(m_real[i]) : 0.0f;
@ -244,9 +244,9 @@ inline hkSimdFloat32 hkSimdFloat32::sqrtUnsafe() const {
inline hkSimdFloat32 hkSimdFloat32::sqrtInverse() const { inline hkSimdFloat32 hkSimdFloat32::sqrtInverse() const {
#ifdef HK_SIMD_FLOAT32_AARCH64_NEON #ifdef HK_SIMD_FLOAT32_AARCH64_NEON
const auto equalsZero = vcle_f32(m_real, vcreate_f32(0)); const auto leqZero = vclez_f32(m_real);
const auto inv = sqrtInverseUnsafe().m_real; const auto inv = sqrtInverseUnsafe().m_real;
return vbic_u32(inv, equalsZero); return vbic_u32(inv, leqZero);
#else #else
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
m_real[i] = m_real[i] > 0.0f ? (1.0f / std::sqrt(m_real[i])) : 0.0f; m_real[i] = m_real[i] > 0.0f ? (1.0f / std::sqrt(m_real[i])) : 0.0f;