public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Naoki Shibata <shibatch.sf.net@gmail.com>,
	GCC Development <gcc@gcc.gnu.org>
Subject: Re: Calls to auto-vectorized AVX512 functions
Date: Mon, 8 Feb 2021 11:55:40 +0100	[thread overview]
Message-ID: <20210208105540.GM4020736@tucnak> (raw)
In-Reply-To: <CAFiYyc0b5gmn5dxK7RTGZVBYv5f4wSNH5YRN9b7+QUZOx6g+QA@mail.gmail.com>

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	other threads:[~2021-02-08 10:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  2:51 Naoki Shibata
2021-02-08 10:42 ` Richard Biener
2021-02-08 10:55   ` Jakub Jelinek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210208105540.GM4020736@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=shibatch.sf.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).