With gcc, you can just use _mm_set_pi64x
:
#include <mmintrin.h> __int64 i = 0x123456LL; __m64 v = _mm_set_pi64x(i);
Note that not all compilers have _mm_set_pi64x
defined in mmintrin.h
. For gcc, it is defined as follows:
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_set_pi64x (long long __i) { return (__m64) __i; }
which suggests that you might just use a listing if you want, for example.
__int64 i = 0x123456LL; __m64 v = (__m64)i;
Otherwise, if you are stuck with an overly attractive compiler like Visual C / C ++, as a last resort, you can simply use the union and implement your own own:
#ifdef _MSC_VER // if Visual C/C++ __inline __m64 _mm_set_pi64x (const __int64 i) { union { __int64 i; __m64 v; } u; ui = i; return uv; }
Please note: strictly speaking, this is UB, since we are writing one version of the union and reading from another, but it should work in this case.
source share