[Bug lto/90500] ICE error in copy_forbiden
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90500 Guobing changed: What|Removed |Added CC||neochen.life at aliyun dot com --- Comment #9 from Guobing --- After applied this patch, I get below errors during compiling with GCC9, while I expect it should be pass as the same as GCC8. ../sysdeps/ieee754/dbl-64/s_tanh.c:97:247: error: clones for ‘target_clones’ attribute cannot be created ../sysdeps/ieee754/dbl-64/s_tanh.c:97:247: note: ‘target_clones’ cannot be combined with ‘alias’ attribute ../sysdeps/ieee754/dbl-64/s_tanh.c:97:135: error: clones for ‘target_clones’ attribute cannot be created ../sysdeps/ieee754/dbl-64/s_tanh.c:97:135: note: ‘target_clones’ cannot be combined with ‘alias’ attribute ../sysdeps/ieee754/dbl-64/s_tanh.c:97:26: error: clones for ‘target_clones’ attribute cannot be created ../sysdeps/ieee754/dbl-64/s_tanh.c:97:26: note: ‘target_clones’ cannot be combined with ‘alias’ attribute
[Bug lto/90500] ICE error in copy_forbiden
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90500 --- Comment #11 from Guobing --- (In reply to Martin Liška from comment #10) > (In reply to Guobing from comment #8) > > Hi, I am the original reporter of this bug. This problem seems not happen on > > GCC8 while do on GCC9. We try to use FMV (target_clone) for some of the > > GlibC libm functions which leads us to this issue. From the Patch below, > > seems this fix the GCC9 crash issue but still not allow target_clone to be > > used together with alias. But this is allowed in GCC8 as we can compile and > > run well under GCC8. So could you help to make the behavior the same as GCC8 > > or tell us a way to walkaround it? > > Well, maybe that was allowed in GCC8, but it was not intentional. Please > describe me your use case and we can come up to a solution that will use > target_clone (or target attribute)? 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.
[Bug lto/90500] ICE error in copy_forbiden
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90500 --- Comment #13 from Guobing --- (In reply to Martin Liška from comment #12) > > 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 & 0x7fff; > ... > } > > 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. The copy is from alias used by libm by default (Below I paste the src code), I cannot remove this copy seems. How can I then to use FMV for this function? __attribute__((target_clones("default", "arch=haswell", "arch=broadwell" ,"arch=skylake", "arch=skylake-avx512"))) double __tanh (double x) { double t, z; int32_t jx, ix, lx; /* High word of |x|. */ EXTRACT_WORDS (jx, lx, x); ix = jx & 0x7fff; /* x is INF or NaN */ if (ix >= 0x7ff0) { if (jx >= 0) return one / x + one; /* tanh(+-inf)=+-1 */ else return one / x - one; /* tanh(NaN) = NaN */ } /* |x| < 22 */ if (ix < 0x4036) /* |x|<22 */ { if ((ix | lx) == 0) return x; /* x == +-0 */ if (ix < 0x3c80) /* |x|<2**-55 */ { math_check_force_underflow (x); return x * (one + x); /* tanh(small) = small */ } if (ix >= 0x3ff0) /* |x|>=1 */ { t = __expm1 (two * fabs (x)); z = one - two / (t + two); } else { t = __expm1 (-two * fabs (x)); z = -t / (t + two); } /* |x| > 22, return +-1 */ } else { z = one - tiny; /* raised inexact flag */ } return (jx >= 0) ? z : -z; } libm_alias_double (__tanh, tanh)
[Bug lto/90500] ICE error in copy_forbiden
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90500 --- Comment #15 from Guobing Chen --- (In reply to Martin Liška from comment #14) > (In reply to Guobing Chen from comment #13) > > (In reply to Martin Liška from comment #12) > > > > 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 & 0x7fff; > > > ... > > > } > > > > > > 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. > > > > The copy is from alias used by libm by default (Below I paste the src code), > > I cannot remove this copy seems. How can I then to use FMV for this > > function? > > > > Then you'll have to make one libm_alias_double_no_copy that will do the same > except setting the copy attribute. I am not quite familiar with libm, will this change the its bevhavior or other side effect?