https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89929

--- Comment #20 from Martin Liška <marxin at gcc dot gnu.org> ---
> 
> Does this mean that if I have an avx512bw+dq function, I'd have to have two
> identical versions of it that I have to target with arch=canonlake and
> arch=amd-something-with-avx512? Seems a bit... unellegant.
> 

If you use target_clone attribute of target attribute in C++ (with
automatically generated resolver function), then yes. You'll need 2 functions,
but you can use alias as seen here:

void xxx () { __builtin_printf ("haswell or skylake CPU\n"); }

void __attribute__ ((target("arch=haswell"),alias("_Z3xxxv"))) foo ();
void __attribute__ ((target("arch=skylake-avx512"),alias("_Z3xxxv"))) foo ();
void __attribute__ ((target("arch=skylake"))) foo () {}
void __attribute__ ((target("default"))) foo () {}

int main()
{
  foo ();
  return 0;
}

Reply via email to