Make preciprocal IEEE compliant w.r.t. 1/0 and 1/inf.

This commit is contained in:
Rasmus Munk Larsen
2022-01-26 20:38:05 +00:00
parent d271a7d545
commit 8f2c6f0aa6
3 changed files with 44 additions and 9 deletions

View File

@@ -148,11 +148,17 @@ Packet4f prsqrt<Packet4f>(const Packet4f& _x) {
return pselect<Packet4f>(not_normal_finite_mask, y_approx, y_newton);
}
#endif
#ifdef EIGEN_VECTORIZE_FMA
// Trying to speed up reciprocal using Newton-Raphson is counterproductive
// unless FMA is available. Without FMA pdiv(pset1<Packet>(Scalar(1),a) is
// 30% faster.
template<> EIGEN_STRONG_INLINE Packet4f preciprocal<Packet4f>(const Packet4f& a) {
return generic_reciprocal_newton_step<Packet4f, /*Steps=*/1>::run(a, _mm_rcp_ps(a));
}
#endif
#endif
// Hyperbolic Tangent function.