What is the effect of second argument in _builtin_prefetch()?
<p>The GCC doc <a href="https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Other-Builtins.html" rel="nofollow noreferrer">here</a> specifies the usage of _buitin_prefetch.</p>

<p>Third argument is perfect. 
If it is 0, compiler generates prefetchtnta (%rax) instruction
If it is 1, compiler generates prefetcht2 (%rax) instruction
If it is 2, compiler generates prefetcht1 (%rax) instruction
If it is 3 (default), compiler generates prefetcht0 (%rax) instruction.</p>

<p>If we vary third argument the opcode already changed accordingly.</p>

<p>But second argument do not seem to have any effect. </p>

<pre><code>__builtin_prefetch(&amp;x,1,2);
__builtin_prefetch(&amp;x,0,2);
__builtin_prefetch(&amp;x,0,1);
__builtin_prefetch(&amp;x,0,0);
</code></pre>

<p>The above is the sample piece of code, that generated:</p>

<p>The following is the assembly: </p>

<pre><code> 27:    0f 18 10                prefetcht1 (%rax)
  2a:   48 8d 45 fc             lea    -0x4(%rbp),%rax
  2e:   0f 18 10                prefetcht1 (%rax)
  31:   48 8d 45 fc             lea    -0x4(%rbp),%rax
  35:   0f 18 18                prefetcht2 (%rax)
  38:   48 8d 45 fc             lea    -0x4(%rbp),%rax
  3c:   0f 18 00                prefetchnta (%rax)
</code></pre>

<p>One can observe the change in opcodes wrt 3rd argument. But even if I changed 2nd argument (that specifies read or write), the assembly code remains the same. &lt;27,2a> and &lt;2e,31>. So it not giving any information to the machine. Then what is the purpose of the second argument? </p>