title: How to detect AVX2 support using gcc
body: <p>I need to detect AVX2 support in my code take decisions accordingly. <br>
  I am aware of two methods - <code>__builtin_cpu_supports(&quot;avx2&quot;)</code> and <code>#if defined(__AVX2__)</code>. Now the issue is one returns true and another false.
  The test code is as follows -</p>
  <pre><code>int main(){
      if(__builtin_cpu_supports(&quot;avx2&quot;)){
          std::cout&lt;&lt; &quot;Builtin methods supports&quot; &lt;&lt; std::endl;
      }
      
      
  #if defined(__AVX2__)
      std::cout&lt;&lt;&quot;Builtin symbol present&quot;&lt;&lt;std::endl;
  #endif
  return 0;
  }
  </code></pre>
  <p>And the output is as follows -</p>
  <pre><code>Builtin methods supports
  </code></pre>
  <p>I am running a i7 - 9750h. And my processor does support <code>AVX2</code> instruction set.</p>
  <p>What is the correct way to identify. My GCC version in 9.3.1</p>