10 #ifndef EIGEN_TYPE_CASTING_SSE_H
11 #define EIGEN_TYPE_CASTING_SSE_H
13 #include "../../InternalHeaderCheck.h"
19 #ifndef EIGEN_VECTORIZE_AVX
21 struct type_casting_traits<float,
bool> {
30 struct type_casting_traits<float, double> {
40 struct type_casting_traits<int, float> {
49 struct type_casting_traits<float, int> {
58 struct type_casting_traits<double, int> {
67 struct type_casting_traits<double, float> {
81 __m128 nonzero_a = _mm_cmpneq_ps(
a, zero);
82 __m128 nonzero_b = _mm_cmpneq_ps(
b, zero);
83 __m128 nonzero_c = _mm_cmpneq_ps(
c, zero);
84 __m128 nonzero_d = _mm_cmpneq_ps(d, zero);
85 __m128i ab_bytes = _mm_packs_epi32(_mm_castps_si128(nonzero_a), _mm_castps_si128(nonzero_b));
86 __m128i cd_bytes = _mm_packs_epi32(_mm_castps_si128(nonzero_c), _mm_castps_si128(nonzero_d));
87 __m128i merged = _mm_packs_epi16(ab_bytes, cd_bytes);
88 return _mm_and_si128(merged, _mm_set1_epi8(1));
92 return _mm_cvttps_epi32(
a);
96 return _mm_cvtepi32_ps(
a);
100 return _mm_shuffle_ps(_mm_cvtpd_ps(
a), _mm_cvtpd_ps(
b), (1 << 2) | (1 << 6));
104 return _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(_mm_cvttpd_epi32(
a)),
105 _mm_castsi128_ps(_mm_cvttpd_epi32(
b)),
106 (1 << 2) | (1 << 6)));
111 return _mm_cvtps_pd(
a);
115 return _mm_castps_pd(
a);
119 return _mm_castpd_ps(
a);
123 return _mm_castps_si128(
a);
127 return _mm_castsi128_ps(
a);
131 return _mm_castsi128_pd(
a);
135 return _mm_castpd_si128(
a);
150 struct type_casting_traits<
Eigen::half, float> {
158 template<> EIGEN_STRONG_INLINE
Packet4f pcast<Packet4h, Packet4f>(
const Packet4h&
a) {
159 __int64_t a64 = _mm_cvtm64_si64(
a.x);
161 float f1 =
static_cast<float>(h);
163 float f2 =
static_cast<float>(h);
165 float f3 =
static_cast<float>(h);
167 float f4 =
static_cast<float>(h);
168 return _mm_set_ps(f4, f3, f2, f1);
172 struct type_casting_traits<float,
Eigen::half> {
180 template<> EIGEN_STRONG_INLINE Packet4h pcast<Packet4f, Packet4h>(
const Packet4f&
a) {
189 result.x = _mm_set_pi16(h3.x, h2.x, h1.x, h0.x);
EIGEN_CONSTEXPR __half_raw raw_uint16_to_half(numext::uint16_t x)
Packet8f pzero(const Packet8f &)
void pstore(Scalar *to, const Packet &from)
Packet2d pcast< Packet4f, Packet2d >(const Packet4f &a)
Packet4f pcast< Packet2d, Packet4f >(const Packet2d &a, const Packet2d &b)
Packet4f preinterpret< Packet4f, Packet4i >(const Packet4i &a)
eigen_packet_wrapper< __m128i, 1 > Packet16b
Packet4ui preinterpret< Packet4ui, Packet4i >(const Packet4i &a)
Packet4i pcast< Packet2d, Packet4i >(const Packet2d &a, const Packet2d &b)
Packet2d preinterpret< Packet2d, Packet4i >(const Packet4i &a)
Packet4i pcast< Packet4f, Packet4i >(const Packet4f &a)
__vector unsigned int Packet4ui
Packet4f pcast< Packet4i, Packet4f >(const Packet4i &a)
Packet4i preinterpret< Packet4i, Packet4f >(const Packet4f &a)
Packet16b pcast< Packet4f, Packet16b >(const Packet4f &a, const Packet4f &b, const Packet4f &c, const Packet4f &d)
Packet2d preinterpret< Packet2d, Packet4f >(const Packet4f &a)
Packet4i preinterpret< Packet4i, Packet2d >(const Packet2d &a)
Packet4f preinterpret< Packet4f, Packet2d >(const Packet2d &a)
Packet4i preinterpret< Packet4i, Packet4ui >(const Packet4ui &a)