On Mon, Feb 08, 2021 at 11:42:13AM +0100, Richard Biener via Gcc wrote:
> > I have a question as to the auto-vectorizer in GCC.
> >
> > When AVX512 instruction is available, the auto-vectorizer in gcc
> > sometimes generates calls to AVX2 functions instead of AVX512 functions.
> >
> >
> > $ cat vabitest.c
> > #include <stdio.h>
> > #include <math.h>
> >
> > _Pragma ("omp declare simd simdlen(8) notinbranch")
> > __attribute__((const)) double myfunc(double x);
> >
> > #define N 1024
> > __attribute__ ((__aligned__(256))) double a[N], b[N], c[N];
> >
> > int main(void) {
> >    for (int i = 0; i < N; i++) a[i] = myfunc(b[i]);
> >    for (int i = 0; i < N; i++) c[i] = sin(b[i]);
> > }
> >
> > $ gcc-10 -ffast-math -O3 -mavx512f -fopenmp vabitest.c -S -o- | grep _ZGV
> >          call    _ZGVdN8v_myfunc@PLT
> >          call    _ZGVeN8v_sin@PLT
> >
> >
> > Is there a way to force gcc to generate calls to AVX512 function in
> > cases like this?
> 
> Not sure, the sin function get's called with a %zmm argument but
> myfunc is called with two %ymm arguments but returns a %zmm.
> Something seems messed up somewhere.
> 
> Can you open a bugreport?

I'd guess it is -mprefer-vector-width=256 by default, though it surprises me
%zmm is used for sin.
In any case, I'd retry with mprefer-vector-width=512.

        Jakub

Reply via email to