title: Why does the FMA _mm256_fmadd_pd() intrinsic have 3 asm mnemonics, "vfmadd132pd", "231" and "213"?
body: <p>Could someone explain to me why there are 3 variants of the fused multiply-accumulate instruction: <code>vfmadd132pd</code>, <code>vfmadd231pd</code> and <code>vfmadd213pd</code>, while there is only one C intrinsics <code>_mm256_fmadd_pd</code>?</p>
  
  <p>To make things simple, what is the difference between (in AT&amp;T syntax)</p>
  
  <pre><code>vfmadd132pd  %ymm0, %ymm1, %ymm2
  vfmadd231pd  %ymm0, %ymm1, %ymm2
  vfmadd213pd  %ymm0, %ymm1, %ymm2
  </code></pre>
  
  <p>I did not get any idea from <a href="https://software.intel.com/sites/landingpage/IntrinsicsGuide/#techs=FMA&amp;expand=2369">Intel's intrinsics guide</a>. I ask because I see all of them in the assembler output of a chunk of C code I wrote. Thanks.</p>
  
  <hr>
  
  <p><strong>A clean answer (re-formating answers below)</strong></p>
  
  <p>For variant <code>ijk</code>, the meaning of <code>vfmaddijkpd</code>:</p>
  
  <ul>
  <li>intel syntax: <code>op(i) * op(j) + op(k) -&gt; op(1)</code></li>
  <li>AT&amp;T syntax: <code>op(4-i) * op(4-j) + op(4-k) -&gt; op(3)</code></li>
  </ul>
  
  <p>where <code>op(n)</code> denotes the n-th operand after the instruction. So there is a <strong>reverse</strong> transform between the two:</p>
  
  <pre><code>n &lt;- 4 - n
  </code></pre>