title: Using avx2 to retrieve and interleave elements from two vectors
body: <p>Given two single-precision floats vectors a and b in avx2 : 
  <br/>a : [0; 1; 2 ; 3; 4; 5; 6; 7]
  <br/>b : [8; 9; 10 ; 11; 12; 13; 14; 15]</p>
  
  <p>I would like to take one element out of two in both vectors and interleave them in the output. Ideally, a control selector would help me to specify which element I choose in both vector (the even or odd ones, let's say). So for a and b the possible outputs would be :</p>
  
  <p><br/>v0: [0; 8; 2; 10; 4; 12; 6; 14]
  <br/>v1: [1; 8; 3; 10; 5; 12; 7; 14]
  <br/>v2: [0; 9; 2; 11; 4; 13; 6; 15]
  <br/>v3: [1; 9; 3; 11; 5; 13; 7; 15]</p>
  
  <p>Blend_ps can do the job for v2 if I'm not mistaken, I need the other ones. Ideally it would take one instruction (I'm confident I can find a solution otherwise, for example by permuting one of the input and then doing a blend). I'm asking because this looks like a quite regular kind of operation, and it does not seem too far-fetched that something like this could be hard-coded in the ISA, but I couldn't find anything completely relevant until now. For example it doesn't do cross-lane accesses.</p>
  
  <p>Unpack_hi and unpack_lo are actually very close, but they interleave at a bigger granularity -  what you get is something of this shape : <br/>[A; A; B; B; A; A; B; B]</p>
  
  <p>Where A (B) denotes an element coming from vector a (b)</p>
  
  <p>Is there such an instruction ?
  Thanks in advance.</p>