title: Will it be feasible to use gcc's function multi-versioning without code changes?
body: <p>According to <a href="https://www.phoronix.com/scan.php?page=article&amp;item=arch-antergos-clear&amp;num=2" rel="nofollow noreferrer">most benchmarks</a>, Intel's Clear Linux is way faster than other distributions, mostly thanks to a GCC feature called <a href="https://lwn.net/Articles/691932/" rel="nofollow noreferrer" title="Function Multi-Versioning">Function Multi-Versioning</a>. Right now the <a href="https://clearlinux.org/documentation/clear-linux/tutorials/fmv" rel="nofollow noreferrer">method</a> they use is to compile the code, analyze which function contains vectorized loops, then patch the code with FMV attributes and compile it again.</p>
  <p>How feasible will it be for GCC to do it automatically? For example, by passing <code>-mmultiarch=sandybridge,skylake</code> (or a similar -m option listing CPU extensions like AVX and AVX2).</p>
  <p>Right now I'm interested in two usage scenarios:</p>
  <ol>
  <li>Use this option for our large math-heavy program for delivering releases to our customers. I don't want to pollute the code with non-standard attributes and I don't want to modify the third-party libraries we use.</li>
  <li>The other Linux distributions will be able to do this easily, without patching the code as Intel does. This should give all Linux users massive performance gains.</li>
  </ol>