mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Correct pnegate for floating-point zero.
This commit is contained in:
@@ -544,11 +544,13 @@ template<> EIGEN_STRONG_INLINE Packet8i psub<Packet8i>(const Packet8i& a, const
|
||||
|
||||
template<> EIGEN_STRONG_INLINE Packet8f pnegate(const Packet8f& a)
|
||||
{
|
||||
return _mm256_sub_ps(_mm256_set1_ps(0.0),a);
|
||||
const Packet8f mask = _mm256_castsi256_ps(_mm256_set1_epi32(0x80000000));
|
||||
return _mm256_xor_ps(a, mask);
|
||||
}
|
||||
template<> EIGEN_STRONG_INLINE Packet4d pnegate(const Packet4d& a)
|
||||
{
|
||||
return _mm256_sub_pd(_mm256_set1_pd(0.0),a);
|
||||
const Packet4d mask = _mm256_castsi256_pd(_mm256_set1_epi64x(0x8000000000000000ULL));
|
||||
return _mm256_xor_pd(a, mask);
|
||||
}
|
||||
template<> EIGEN_STRONG_INLINE Packet8i pnegate(const Packet8i& a)
|
||||
{
|
||||
|
||||
@@ -346,11 +346,13 @@ EIGEN_STRONG_INLINE Packet16i psub<Packet16i>(const Packet16i& a,
|
||||
|
||||
template <>
|
||||
EIGEN_STRONG_INLINE Packet16f pnegate(const Packet16f& a) {
|
||||
return _mm512_sub_ps(_mm512_set1_ps(0.0), a);
|
||||
const __m512i mask = _mm512_set1_epi32(0x80000000);
|
||||
return _mm512_castsi512_ps(_mm512_xor_epi32(_mm512_castps_si512(a), mask));
|
||||
}
|
||||
template <>
|
||||
EIGEN_STRONG_INLINE Packet8d pnegate(const Packet8d& a) {
|
||||
return _mm512_sub_pd(_mm512_set1_pd(0.0), a);
|
||||
const __m512i mask = _mm512_set1_epi64(0x8000000000000000ULL);
|
||||
return _mm512_castsi512_pd(_mm512_xor_epi64(_mm512_castpd_si512(a), mask));
|
||||
}
|
||||
template <>
|
||||
EIGEN_STRONG_INLINE Packet16i pnegate(const Packet16i& a) {
|
||||
|
||||
Reference in New Issue
Block a user