title: How can I convert a vector of float to short int using avx instructions?
body: <p>Basically how can I write the equivalent of this with AVX2 intrinsics? We assume here that <code>result_in_float</code> is of type <code>__m256</code>, while <code>result</code> is of type <code>short int*</code> or <code>short int[8]</code>. </p>
  
  <pre><code>for(i = 0; i &lt; 8; i++)
      result[i] = (short int)result_in_float[i];
  </code></pre>
  
  <p>I know that floats can be converted to 32 bit integers using the <code>__m256i _mm256_cvtps_epi32(__m256 m1)</code> intrinsic, but have no idea how to convert these 32 bit integers further to 16 bit integers. And I don't want just that but also to store those values (in the form of 16 bit integers) to the memory, and I want to do that all using vector instructions. </p>
  
  <p>Searching around the internet, I found an intrinsic by the name of<code>_mm256_mask_storeu_epi16</code>, but I'm not really sure if that would do the trick, as I couldn't find an example of its usage.</p>