title: Intel AVX: 256-bits version of dot product for double precision floating point variables
body: <p>The Intel Advanced Vector Extensions (AVX) offers no <strong>dot product in the 256-bit version (YMM register) for double precision floating point variables</strong>. The "Why?" question have been very briefly treated in another forum (<a href="http://www.amdzone.com/phpbb3/viewtopic.php?f=532&amp;t=139130" rel="noreferrer">here</a>) and on Stack&nbsp;Overflow (<a href="https://stackoverflow.com/questions/16033266/intel-avx-why-is-there-no-256-bits-version-of-dot-product-for-double-precision">here</a>). But the question I am facing is how to replace this missing instruction with other AVX instructions in an efficient way?</p>
  
  <p>The dot product in 256-bit version exists for single precision floating point variables (<a href="http://denali.princeton.edu/IntelXe2011/compiler_c/main_cls/intref_cls/common/intref_avx_dp_ps.htm" rel="noreferrer">reference here</a>):</p>
  
  <pre><code> __m256 _mm256_dp_ps(__m256 m1, __m256 m2, const int mask);
  </code></pre>
  
  <p>The idea is to find an efficient equivalent for this missing instruction:</p>
  
  <pre><code> __m256d _mm256_dp_pd(__m256d m1, __m256d m2, const int mask);
  </code></pre>
  
  <p>To be more specific, the code I would like to transform from <code>__m128</code> (four floats) to <code>__m256d</code> (4 doubles) use the following instructions:</p>
  
  <pre><code>   __m128 val0 = ...; // Four float values
     __m128 val1 = ...; //
     __m128 val2 = ...; //
     __m128 val3 = ...; //
     __m128 val4 = ...; //
  
     __m128 res = _mm_or_ps( _mm_dp_ps(val1,  val0,   0xF1),
                  _mm_or_ps( _mm_dp_ps(val2,  val0,   0xF2),
                  _mm_or_ps( _mm_dp_ps(val3,  val0,   0xF4),
                             _mm_dp_ps(val4,  val0,   0xF8) )));
  </code></pre>
  
  <p>The result of this code is a <code>_m128</code> vector of four floats containing the results of the dot products between <code>val1</code> and <code>val0</code>, <code>val2</code> and <code>val0</code>, <code>val3</code> and <code>val0</code>, <code>val4</code> and <code>val0</code>.</p>
  
  <p>Maybe this can give hints for the suggestions?</p>