title: How to load bytes in a __m128i in a specific position
body: <p>I need to load 4 bytes stored consecutively in an array in a specific position of a __m128i variable, namely to be able to do many int32_t sums, 4 at a time, storing all partial results.</p>
  
  <p>For example:</p>
  
  <pre><code>const unsigned int SIZE = 2000000;
  const unsigned int STEP = 100;
  
  unsigned char* inBuffer = new char[SIZE];
  //Fill inBuffer
  const unsigned char* a = inBuffer;
  
  int32_t* outBuffer = new int32_t[SIZE/STEP*4];
  int32_t* result = outBuffer;
  
  __m128i sum = _mm_setzero_si128 ()
  for (int i = 0; i &lt; SIZE; i+=STEP) {
      __m128i value = _mm_set_epi32 (a[3],a[2],a[1],a[0]);
      sum = __mm_add_epi32(sum,value);
      _mm_storeu_si128 ((__m128i*)result,sum);
      a+=STEP;
      result+=4;
      }
  
  //Print outBuffer
  
  delete[] inBuffer;
  delete[] outBuffer;
  </code></pre>
  
  <p>I was wondering if there was a more efficient way to do so</p>