Skip to content

Commit

Permalink
Only use _mm_insert_epi64 on 64 bit architecture
Browse files Browse the repository at this point in the history
Provide a fallback based on _mm_insert_epi32 on 32 bit architecture.

Fix #860
  • Loading branch information
serge-sans-paille committed Nov 11, 2022
1 parent c9387c6 commit 07df435
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/xsimd/arch/xsimd_sse4_1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ namespace xsimd
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
{
return _mm_insert_epi32(self, val, I);
#if !defined(_MSC_VER) || _MSC_VER > 1900 && defined(_M_X64)
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
{
#if (!defined(_MSC_VER) && __x86_64__) || (_MSC_VER > 1900 && defined(_M_X64))
return _mm_insert_epi64(self, val, I);
#else
uint32_t lo, hi;
memcpy(&lo, (reinterpret_cast<uint32_t*>(&val)), sizeof(lo));
memcpy(&hi, (reinterpret_cast<uint32_t*>(&val)) + 1, sizeof(hi));
return _mm_insert_epi32(_mm_insert_epi32(self, lo, 2 * I), hi, 2 * I + 1);
#endif
}
else
Expand Down

0 comments on commit 07df435

Please sign in to comment.