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

--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
> The background is that, we want to try optimize libm with avx2/avx512, and
> found that not all the libm math functions will have benefit when we
> generally use 'arch=haswell' or 'arch=skylake-avx512' to compile libm. So we
> picked those 'good' libm math functions to add FMV attribute like
> target_clone("default", "arch=haswell", "arch=skylake-avx512") to get
> performance benefit. The alias is used in libm code by default. I have no
> idea why these two are conflicting that not allowed by GCC9.

That makes sense. Based on the test-case you provided, you just want:

__attribute__((target_clones("default", "arch=haswell",
"arch=skylake-avx512")))
double
__tanh (double x)
{
  double t, z;
  int32_t jx, ix, lx;


  do { ieee_double_shape_type ew_u; ew_u.value = (x); (jx) = ew_u.parts.msw;
(lx) = ew_u.parts.lsw; } while (0);
  ix = jx & 0x7fffffff;
...
}

extern __typeof (__tanh) tanh __attribute__ ((weak, alias ("__tanh"))); //
__attribute__ ((__copy__ (__tanh)));

You don't want to use __copy__ attribute because it's responsible for copying
of target_clone attribute to the alias.
And it does not make sense to create clones of an alias.

Reply via email to