title: SSE extracting integers from a __m128 for indexing an array
body: <p>In some code I have converted to SSE I preform some ray tracing, tracing 4 rays at a time using __m128 data types.</p>
  
  <p>In the method where I determine which objects are hit first, I loop through all objects, test for intersection and create a mask representing which rays had an intersection earlier than previously found .</p>
  
  <p>I also need to maintain data on the id of the objects which correspond to the best hit times. I do this by maintaining a __m128 data type called objectNo and I use the mask determined from the intersection times to update objectNo as follows:</p>
  
  <pre><code>objectNo = _mm_blendv_ps(objectNo,_mm_set1_ps((float)pobj-&gt;getID()),mask);
  </code></pre>
  
  <p>Where pobj->getID() will return an integer representing the id of the current object. Making this cast and using the blend seemed to be the most efficient way of updating the objectNo for all 4 rays.</p>
  
  <p>After all intersections are tested I try to extract the objectNo's individually and use them to access an array to register the intersection. Most commonly I have tried this:</p>
  
  <pre><code>int o0 = _mm_extract_ps(objectNo, 0);
  prv_noHits[o0]++;
  </code></pre>
  
  <p>However this crashes with EXC_BAD_ACCESS as extracting a float with value 1.0 converts to an int of value 1065353216. </p>
  
  <p>How do I correctly unpack the __m128 into ints which can be used to index an array?</p>