title: AVX instructions generated when -xSSE4.1 specified
body: <p>I have compiled a piece of code with the option -xSSE4.1 using the Intel compiler. When I looked at the generated assembly file, I see that AVX instructions such as 'vpmovzxbw' have been inserted. But, the executable still seems to run on machines that don't support the AVX instruction set. What explains this?</p>
  
  <p>Here's the particular code snippet - </p>
  
  <pre><code>C -&gt; src0_8x16b  = _mm_cvtepu8_epi16 (src0_8x16b);
  
  Assembly -&gt; vpmovzxbw xmm4, QWORD PTR [rcx]
  
  Binary -&gt; 00066 c4 62 79 30 29   
  </code></pre>
  
  <p>Here's another snippet where the assembly instruction uses 3 operands -</p>
  
  <pre><code>C -&gt; src0_8x16b = _mm_sub_epi16 (src0_8x16b, src1_8x16b);
  
  Assembly -&gt; vpsubw xmm1, xmm13, xmm11              
  
  Binary -&gt; 000bc c4 c1 11 f9 cb   
  </code></pre>
  
  <p>For comparison, here's the disassembly generated by icc for the function 'foo' <em>(The only difference between the function foo and the code snippet above is that the code snippet was coded using intrinsics)</em> -</p>
  
  <pre><code>Compiler commands used - 
  icc -S -xSSE4.1 -axavx -O3 foo.c
  
  Function foo -
  void foo(float *x, int n) 
  {
      int i;
  
      for(i=0; i&lt;n; i++) x[i] *= 2.0;
  }
  
  Autodispatch code - 
  testl     $-131072, __intel_cpu_indicator(%rip)         #1.27
  jne       foo.R                                         #1.27
  testl     $-1, __intel_cpu_indicator(%rip)              #1.27
  jne       foo.A
  
  Loop in foo.R (AVX variant) - 
  vmulps    (%rdi,%rcx,4), %ymm0, %ymm1                   #3.24
  vmulps    32(%rdi,%rcx,4), %ymm0, %ymm2                 #3.24
  vmovups   %ymm1, (%rdi,%rcx,4)                          #3.24
  vmovups   %ymm2, 32(%rdi,%rcx,4)                        #3.24
  addq      $16, %rcx                                     #3.5
  cmpq      %rdx, %rcx                                    #3.5
  jb        ..B2.12       # Prob 82%                      #3.5
  
  Loop in foo.A (SSE variant) - 
  movaps    (%rdi,%r8,4), %xmm1                           #3.24
  movaps    16(%rdi,%r8,4), %xmm2                         #3.24
  mulps     %xmm0, %xmm1                                  #3.24
  mulps     %xmm0, %xmm2                                  #3.24
  movaps    %xmm1, (%rdi,%r8,4)                           #3.24
  movaps    %xmm2, 16(%rdi,%r8,4)                         #3.24
  addq      $8, %r8                                       #3.5
  cmpq      %rsi, %r8                                     #3.5
  jb        ..B3.12       # Prob 82%                      #3.5
  </code></pre>