public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512
@ 2021-02-15 5:23 shibatch.sf.net at gmail dot com
2021-02-15 8:36 ` [Bug tree-optimization/99100] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: shibatch.sf.net at gmail dot com @ 2021-02-15 5:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
Bug ID: 99100
Summary: Inconsistent vector length used in autovectorizer for
AVX-512
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: shibatch.sf.net at gmail dot com
Target Milestone: ---
When AVX512 instruction is available, the auto-vectorizer in gcc
sometimes generates calls to AVX2 functions instead of AVX512 functions.
-mprefer-vector-width=512 does not affect the result.
$ 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/99100] Inconsistent vector length used in autovectorizer for AVX-512
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
@ 2021-02-15 8:36 ` rguenth at gcc dot gnu.org
2021-02-15 9:01 ` [Bug target/99100] " rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-15 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-02-15
Keywords| |missed-optimization
Component|target |tree-optimization
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Blocks| |53947
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. I suspect the logic selecting the overload to use in the vectorizer
is flawed.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/99100] Inconsistent vector length used in autovectorizer for AVX-512
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
2021-02-15 8:36 ` [Bug tree-optimization/99100] " rguenth at gcc dot gnu.org
@ 2021-02-15 9:01 ` rguenth at gcc dot gnu.org
2021-02-15 9:43 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-15 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |target
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
What's odd is that with -mavx512f -mtune=skylake-avx512 we don't vectorize it
at all. I'm looking at a smaller test:
#pragma omp declare simd simdlen(8) notinbranch
extern double __attribute__((const)) myfunc(double x);
#define N 1024
__attribute__ ((__aligned__(256))) double a[N], b[N], c[N];
void foo()
{
for (int i = 0; i < N; i++) a[i] = myfunc(b[i]);
}
we have 3 simd clones here and the only discriminator is the target badness
returned by targetm.simd_clone.usable (n). I suspect
switch (node->simdclone->vecsize_mangle)
{
case 'b':
if (!TARGET_SSE2)
return -1;
if (!TARGET_AVX)
return 0;
return TARGET_AVX2 ? 2 : 1;
case 'c':
if (!TARGET_AVX)
return -1;
return TARGET_AVX2 ? 1 : 0;
case 'd':
if (!TARGET_AVX2)
return -1;
return 0;
case 'e':
if (!TARGET_AVX512F)
return -1;
return 0;
since 'd' behaves the same as 'e' here we prefer 'd' or 'e' dependent on
the order in the simd clones.
Note the odd thing is we produce a 'c' mangling clone _and_ a 'd' mangling
one. But indeed once we reach 'd' badness is zero and can't improve anymore.
There's also no sign of handling of prefered SIMD modes in the above
function...
Target issue. Not sure about the -mtune=skylake-avx512 issue though.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/99100] Inconsistent vector length used in autovectorizer for AVX-512
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
2021-02-15 8:36 ` [Bug tree-optimization/99100] " rguenth at gcc dot gnu.org
2021-02-15 9:01 ` [Bug target/99100] " rguenth at gcc dot gnu.org
@ 2021-02-15 9:43 ` jakub at gcc dot gnu.org
2021-02-16 8:01 ` cvs-commit at gcc dot gnu.org
2021-02-16 8:03 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-15 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50184
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50184&action=edit
gcc11-pr99100.patch
Untested fix.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/99100] Inconsistent vector length used in autovectorizer for AVX-512
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
` (2 preceding siblings ...)
2021-02-15 9:43 ` jakub at gcc dot gnu.org
@ 2021-02-16 8:01 ` cvs-commit at gcc dot gnu.org
2021-02-16 8:03 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-16 8:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:1531f39268c8973cf9478585fba5c5bbdb6e9c4c
commit r11-7253-g1531f39268c8973cf9478585fba5c5bbdb6e9c4c
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Feb 16 08:59:03 2021 +0100
openmp: Fix up vectorization simd call badness computation [PR99100]
As mentioned in the PR, ix86_simd_clone_usable didn't make it more
desirable
to use 'e' mangled AVX512F entrypoints over 'd' mangled ones (AVX2) with
the
same simdlen. This patch fixes that. I have tweaked the generic code too
to make more room for these target specific badness factors.
2021-02-16 Jakub Jelinek <jakub@redhat.com>
PR target/99100
* tree-vect-stmts.c (vectorizable_simd_clone_call): For num_calls
!= 1
multiply by 4096 and for inbranch by 8192.
* config/i386/i386.c (ix86_simd_clone_usable): For TARGET_AVX512F,
return 3, 2 or 1 for mangle letters 'b', 'c' or 'd'.
* gcc.target/i386/pr99100.c: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/99100] Inconsistent vector length used in autovectorizer for AVX-512
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
` (3 preceding siblings ...)
2021-02-16 8:01 ` cvs-commit at gcc dot gnu.org
@ 2021-02-16 8:03 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-16 8:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99100
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk, not sure about backporting yet.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-16 8:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 5:23 [Bug c/99100] New: Inconsistent vector length used in autovectorizer for AVX-512 shibatch.sf.net at gmail dot com
2021-02-15 8:36 ` [Bug tree-optimization/99100] " rguenth at gcc dot gnu.org
2021-02-15 9:01 ` [Bug target/99100] " rguenth at gcc dot gnu.org
2021-02-15 9:43 ` jakub at gcc dot gnu.org
2021-02-16 8:01 ` cvs-commit at gcc dot gnu.org
2021-02-16 8:03 ` jakub at gcc dot gnu.org
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).