title: AVX2 VPSHUFB emulation in AVX
body: <p>In AVX there's only 128 bits <code>PSHUFB</code></p>
  
  <pre><code>VPSHUFB xmm1, xmm2, xmm3/m128
  </code></pre>
  
  <p>and only AVX2 has the full <code>PSHUFB</code> for the whole 256 bits AVX registers</p>
  
  <pre><code>VPSHUFB ymm1, ymm2, ymm3/m256
  </code></pre>
  
  <p><strong>How can this instruction be emulated efficiently with AVX intrinsics?</strong></p>
  
  <p>Also in this particular case, the source only has 8 elements (bytes) but those could be moved around within the full 32 bytes of the destination. So it's no problem for running just 2 x <code>PSHUFB</code>.</p>
  
  <p>A problem I'm finding with <code>VPSHUFB</code> is it treats 16 (0x10) as 0, only 128 and up are filled with zero! (highest bit set) Is it possible to do it without adding compares and masking out?</p>