On 09/21/2015 07:25 AM, Bernd Schmidt wrote:
On 08/27/2015 01:18 PM, Evgeny Stupachenko wrote:
Based on RFC:
https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01322.html
The patch implement an extension to Function Multiversioning that
allows to clone a function for multiple targets.
__attribute__((target_clones("avx","arch=slm","default")))
int foo ()
...
Will create 3 clones of foo(). One optimized with -mavx, one optimized
with -march=slm, and one with default optimizations.
And will create ifunc resolver that calls appropriate clone (same as
in Function Multiversioning).
The general question is - do we want this, given that it seems to
introduce no functionality that can't be had with the existing
multiversioning? You could always compile the same source file to
multiple objects with different defines for the target optimization, or
include a file containing the multiversioned function multiple times
with changing #defines.
Essentially it allows us to more easily support
per-microarchitecture-optimized versions of functions. You list just
have to list the microarchitectures and the compiler handles the rest.
Very simple, very easy. I'd think it'd be particularly helpful for
vectorization.
You could emulate this with compiling the same source multiple times
with different flags/defines and wire up on ifunc by hand. But Evgeny's
approach is vastly simpler.
We are still waiting on Jan to chime in as to whether or not any of this
breaks the rules WRT nodes in the symbol table. Given I mucked up the
MPX code by not knowing those rules, I'm hesitant to approve this patch
without input from Jan.
Jeff