Atomic test-and-set in x86: inline asm or compiler-generated lock bts?
<p>The below code when compiled for a xeon phi throws 
<code>Error: cmovc is not supported on k1om</code>.</p>

<p>But it does compile properly for a regular xeon processor.</p>

<pre><code>#include&lt;stdio.h&gt;
int main()
{
    int in=5;
    int bit=1;
    int x=0, y=1;
    int&amp; inRef = in;
    printf("in=%d\n",in);
    asm("lock bts %2,%0\ncmovc %3,%1" : "+m" (inRef), "+r"(y) : "r" (bit), "r"(x));
    printf("in=%d\n",in);
}
</code></pre>

<p>Compiler - <code>icc (ICC) 13.1.0 20130121</code></p>

<p>Related question: <a href="https://stackoverflow.com/questions/22980352/bit-test-and-set-bts-on-a-tbb-atomic-variable">bit test and set (BTS) on a tbb atomic variable</a></p>