Hello. Not being expert in multi_target area, however it consists of 2 passes. The first one (ipa_target_clone) is responsible for creation of multiple targets for functions decorated with __attribute__((target_clones("xxx"))). I guess the pass should be called just in LGEN phase and consecutive clone materialization takes care of these clones. I'm also adding lto test-case.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. mvc test-cases work find on x86_64-linux-gnu. Ready to be installed? Martin
>From 7ec7045680e10838c43b2713a4fa34b205ba5004 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Fri, 13 Jan 2017 15:26:45 +0100 Subject: [PATCH] Make multiple_target.c aware of LTO (PR lto/66295) gcc/ChangeLog: 2017-01-13 Martin Liska <mli...@suse.cz> PR lto/66295 * multiple_target.c (pass_target_clone::gate): Run the pass just in LGEN (in LTO mode). gcc/testsuite/ChangeLog: 2017-01-13 Martin Liska <mli...@suse.cz> PR lto/66295 * gcc.target/i386/mvc9.c: New test. --- gcc/multiple_target.c | 2 +- gcc/testsuite/gcc.target/i386/mvc9.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/mvc9.c diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index 5be3980db20..3df1e297122 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -378,7 +378,7 @@ public: bool pass_target_clone::gate (function *) { - return true; + return !flag_wpa && !flag_ltrans; } } // anon namespace diff --git a/gcc/testsuite/gcc.target/i386/mvc9.c b/gcc/testsuite/gcc.target/i386/mvc9.c new file mode 100644 index 00000000000..d510b6c18b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mvc9.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto" } */ + +__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default"))) +int +foo () +{ + return -2; +} + +int +bar () +{ + return 2; +} + +int +main () +{ + int r = 0; + r += bar (); + r += foo (); + r += bar (); + r += foo (); + r += bar (); + return r - 2; +} -- 2.11.0