问题
I've recently played around with the target_clones
attribute available from gcc 6.1 and onward. It's quite nifty, but, for now, it requires a somewhat clumsy approach; every function that one wants multi-versioned has to have an attribute declared manually. This is less than optimal because:
- It puts compiler-specific stuff in the code.
- It requires the developer to identify which functions should receive this treatment.
Let's take the example where I want to compile some code that will take advantage of AVX2 instructions, where available. -fopt-info-vect
will tell me which functions were vectorized, if I build with -mavx2
, so the compiler already knows this. Is there a way to, globally, tell the compiler: "If you find a function which you feel could be optimized with AVX2, make multiple versions, with and without AVX2, of that function."? And if not, can we have one, please?
来源:https://stackoverflow.com/questions/39979926/is-there-or-will-there-be-a-global-version-of-the-target-clones-attribute