title: Load __m64 from a 64-bit integer type?
body: <p>I'm porting a routine written with Intel SSE2 intrinsics to Microsoft 32-bit platforms. It works fine under GCC, Clang and 64-bit Windows. The original code effectively performs the following:</p>
  
  <pre><code>typedef unsigned __int64 word64;
  
  // input is aligned on 16-byte boundary
  void (const byte* input)
  {
      const word64 m0 = ((const word64*)input)[ 0];
      const word64 m1 = ((const word64*)input)[ 8];
      ...
  
      __m128 t0 = _mm_set_epi64x(m0, m1);
  }
  </code></pre>
  
  <p>Microsoft does not provide <a href="http://msdn.microsoft.com/en-us/library/dk2sdw0h%28v=vs.100%29.aspx" rel="nofollow"><code>_mm_set_epi64x</code></a> on 32-bit platforms, so I want to use <a href="http://msdn.microsoft.com/en-us/library/ecz16x1z%28v=vs.100%29.aspx" rel="nofollow"><code>_mm_set_epi64</code></a>.</p>
  
  <p>Now the problems... First,</p>
  
  <pre><code>__m64 m0, m1;
  m0 = *(word64*)(input+0);
  </code></pre>
  
  <p>Results in:</p>
  
  <pre class="lang-none prettyprint-override"><code>1&gt;  error C2679: binary '=' : no operator found which takes a right-hand operand
  of type 'word64' (or there is no acceptable conversion)
  1&gt;  c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\mmintrin.h(42):
  could be '__m64 &amp;__m64::operator =(const __m64 &amp;)'
  1&gt;  while trying to match the argument list '(__m64, word64)'
  </code></pre>
  
  <p>Second, trying to sidestep the potential issue with <code>word64</code> and use <code>unsigned __int64*</code> directly:</p>
  
  <pre><code>m0 = *(unsigned __int64*)(input+0);
  </code></pre>
  
  <p>Results in the same:</p>
  
  <pre class="lang-none prettyprint-override"><code>1&gt;  blake2.cpp(530): error C2679: binary '=' : no operator found which takes a right-hand
  operand of type 'unsigned __int64' (or there is no acceptable conversion)
  </code></pre>
  
  <p>Third, I looked through <code>&lt;mmintrin.h&gt;</code> and found <code>_m_from_int</code>:</p>
  
  <pre><code>m0 = _m_from_int(*(word64*)(input+0));
  </code></pre>
  
  <p>It results in:</p>
  
  <pre class="lang-none prettyprint-override"><code>1&gt;  blake2.cpp(529): warning C4244: 'argument' : conversion from 'word64'
  to 'int', possible loss of data
  </code></pre>
  
  <p>I'm not sure what else to try at this point.</p>
  
  <p>How do I load a <code>__m64</code> from a 64-bit integer type?</p>
  
  <hr>
  
  <p>Below is Microsoft's declaration of <code>__m64</code>, but we are supposed to treat it as opaque:</p>
  
  <pre><code>typedef union __declspec(intrin_type) _CRT_ALIGN(8) __m64
  {
      unsigned __int64    m64_u64;
      float               m64_f32[2];
      __int8              m64_i8[8];
      __int16             m64_i16[4];
      __int32             m64_i32[2];    
      __int64             m64_i64;
      unsigned __int8     m64_u8[8];
      unsigned __int16    m64_u16[4];
      unsigned __int32    m64_u32[2];
  } __m64;
  </code></pre>