On Mon, Feb 8, 2021 at 4:26 AM Naoki Shibata via Gcc <gcc@gcc.gnu.org> wrote:
>
>
> Hello,
>
> 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?

Richard.

> Regards,
>
> Naoki Shibata

Reply via email to