https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129033
--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
I can imagine that this is a very common operation in some domains, but most
people would write it as one of these two (suboptimal) options:
double *
memmove_minmax_mult(double * restrict dst, const double * restrict src,
const double * restrict minmax, dimension_t dim)
{
// GCC/Clang convert this to vectorized and+xor without multiplication.
for (dimension_t d = 0; d < dim; d++) {
dst[d] = src[d] * minmax[d];
}
return dst;
}
double *
memmove_minmax_cond(double * restrict dst, const double * restrict src,
const double * restrict minmax, dimension_t dim)
{
// GCC/Clang convert this to vectorized and+xor without multiplication.
for (dimension_t d = 0; d < dim; d++) {
dst[d] = (minmax[d] < 0) ? -src[d] : src[d];
}
return dst;
}