title: Problems with AVX computations: can I run avx2 codes?
body: <p>I've been using Intel's SSE instructions with good performance gains and, recently, I tried to use AVX instructions.</p>
  
  <p>The problem is: I can compile my avx instructions, but I cannot run them. The instructions are:</p>
  
  <pre><code>__m256i* avx1 = (__m256i*)vct1;
  __m256i* avx2 = (__m256i*)vct2;
  __m256i* avx3 = (__m256i*)vct3;
  
  __m256i va0, va1, va2;            
  
  va2 = _mm256_and_si256(va0, va1);
  </code></pre>
  
  <p>The only way I can compile these instructions is by having -mavx2 flag. Without this flag I can't compile the code and I received this error:</p>
  
  <pre><code>"sseAND.cpp:124:33: error: ‘_mm256_and_si256’ was not declared in this scope
    va2 = _mm256_and_si256(va0, va1); 
  "
  </code></pre>
  
  <p>Ok, after compilling with -mavx2 and running the code, I received this error messagem:</p>
  
  <p><code>"Illegal Instruction</code>".</p>
  
  <p>Running <code>/proc/cpuinfo</code>, I saw my Sandy Bridge CPU has support only for AVX instructions, not AVX2.</p>
  
  <p>The question Is: is there anything wrong with my code or with my gcc flags?</p>
  
  <p>Can I run the avx instructions I put below in my Sandybridge?</p>
  
  <p>Thanks for your help.</p>