Is there, or will there be, a “global” version of the target_clones attribute?

末鹿安然 提交于 2019-12-07 02:57:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!