You can't apply both 'ctarget' and 'target' attributes to a function. The patch uses same target specific methods to create dispatcher and target clones.
On Fri, Jul 31, 2015 at 1:30 AM, Andrew Pinski <pins...@gmail.com> wrote: > On Thu, Jul 30, 2015 at 3:19 PM, Evgeny Stupachenko <evstu...@gmail.com> > wrote: >> Hi All, >> >> The patch enables new attribute 'ctarget', >> The attribute force compiler to create clones of a function with the >> attribute. >> >> For example: >> __attribute__((ctarget("avx","arch=slm","arch=core-avx2","default"))) >> int >> foo () >> >> will create 3 clones of foo() optimized for corresponding targets and >> replace all foo() calls with ifunc resolver. >> The patch include new tests for the feature. >> >> Currently default ctarget means that foo() will be optimized with >> current compiler options and target. >> The other option is to switch target to target specific minimum (like >> target x86-64). Is it better? >> >> What do you think about attribute name? 'ctarget' is short but not >> informative. Other variants are 'target_clones', 'targets'... > > How does this interacts with Function Multiversioning > (https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/Function-Multiversioning.html)? > > Thanks, > Andrew Pinski > >> >> Below is ChangeLog. Attached patch passed make check on x86. >> >> Thanks, >> Evgeny >> >> 2015-07-31 Evgeny Stupachenko <evstu...@gmail.com> >> >> gcc/ >> * Makefile.in (OBJS): Add multiple_target.o. >> * multiple_target.c (make_attribute): New. >> (create_dispatcher_calls): Ditto. >> (expand_target_clones): Ditto. >> (ipa_target_clone): Ditto. >> * passes.def (pass_target_clone): New ipa pass. >> * tree-pass.h (make_pass_target_clone): Ditto. >> >> gcc/c-family >> * c-common.c (handle_ctarget_attribute): New. >> * (c_common_attribute_table): Add handle_ctarget_attribute. >> * (handle_always_inline_attribute): Add check on ctarget attribute. >> * (handle_target_attribute): Ditto. >> >> gcc/testsuite >> * gcc.dg/mvc1.c: New test for multiple targets cloning. >> * gcc.dg/mvc2.c: Ditto. >> * gcc.dg/mvc3.c: Ditto. >> * gcc.dg/mvc4.c: Ditto. >> * gcc.dg/mvc5.c: Ditto. >> * gcc.dg/mvc6.c: Ditto. >> * gcc.dg/mvc7.c: Ditto. >> * g++.dg/ext/mvc1.C: Ditto. >> * g++.dg/ext/mvc2.C: Ditto. >> * g++.dg/ext/mvc3.C: Ditto.