public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons
@ 2024-06-14 4:14 andi-gcc at firstfloor dot org
2024-06-14 5:51 ` [Bug tree-optimization/115484] if-to-switch prevents AVX vectorization rguenth at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: andi-gcc at firstfloor dot org @ 2024-06-14 4:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
Bug ID: 115484
Summary: AVX vectorization is limited to 3 comparisons
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: andi-gcc at firstfloor dot org
Target Milestone: ---
With current trunk, but also older gcc
int f(char *s)
{
int c = 0;
int i;
for (i = 0; i < 64; i++) {
c |= (*s == ',' || *s == '|' || *s == '!' /* || *s == '*' */);
s++;
}
return c;
}
vectorizes with -O3 -mavx2 -fopt-info-optall-all tvcmp.c
tvcmp.c:6:16: optimized: loop vectorized using 16 byte vectors
tvcmp.c:2:5: note: vectorized 1 loops in function.
tvcmp.c:7:10: optimized: loop with 3 iterations completely unrolled (header
execution count 16535624)
but when the fourth comparison is commented in it doesn't:
BB 3 is always executed in loop 1
loop 1's coldest_outermost_loop is 1, hotter_than_inner_loop is NULL
tvcmp.c:6:16: missed: couldn't vectorize loop
tvcmp.c:6:16: missed: not vectorized: unsupported control flow in loop.
tvcmp.c:2:5: note: vectorized 0 loops in function.
tvcmp.c:10:9: note: ***** Analysis failed with vector mode V16QI
tvcmp.c:10:9: note: ***** Skipping vector mode V16QI, which would repeat the
analysis for V16QI
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
@ 2024-06-14 5:51 ` rguenth at gcc dot gnu.org
2024-06-15 0:54 ` [Bug tree-optimization/115484] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-14 5:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|AVX vectorization is |if-to-switch prevents AVX
|limited to 3 comparisons |vectorization
Ever confirmed|0 |1
Last reconfirmed| |2024-06-14
Blocks| |53947
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Target| |x86_64-*-*
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue seems to be that if-to-switch creates a switch () once you get to
four
conditions and switch statements are not handled by the pre-vectorizer
if-conversion (or by vectorization natively).
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [11/12/13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
2024-06-14 5:51 ` [Bug tree-optimization/115484] if-to-switch prevents AVX vectorization rguenth at gcc dot gnu.org
@ 2024-06-15 0:54 ` sjames at gcc dot gnu.org
2024-06-15 1:02 ` [Bug tree-optimization/115484] [13/14/15 " sjames at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-15 0:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|if-to-switch prevents AVX |[11/12/13/14/15 regression]
|vectorization |if-to-switch prevents AVX
| |vectorization
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
GCC 8 vectorises it: https://godbolt.org/z/Y8Pvxsh5c.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
2024-06-14 5:51 ` [Bug tree-optimization/115484] if-to-switch prevents AVX vectorization rguenth at gcc dot gnu.org
2024-06-15 0:54 ` [Bug tree-optimization/115484] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
@ 2024-06-15 1:02 ` sjames at gcc dot gnu.org
2024-06-15 1:03 ` sjames at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-15 1:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13/14/15 regression] |[13/14/15 regression]
|if-to-switch prevents AVX |if-to-switch prevents AVX
|vectorization |vectorization
--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Sam James from comment #2)
> GCC 8 vectorises it: https://godbolt.org/z/Y8Pvxsh5c.
Not only does 8 vectorise it, but so does GCC 11, GCC 12. So, 9/13/14/15 are
broken.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
` (2 preceding siblings ...)
2024-06-15 1:02 ` [Bug tree-optimization/115484] [13/14/15 " sjames at gcc dot gnu.org
@ 2024-06-15 1:03 ` sjames at gcc dot gnu.org
2024-06-15 1:06 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-15 1:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
Not only does 8 vectorise it, but so does GCC 11, GCC 12. So, 9/10/13/14/15 are
broken.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
` (3 preceding siblings ...)
2024-06-15 1:03 ` sjames at gcc dot gnu.org
@ 2024-06-15 1:06 ` pinskia at gcc dot gnu.org
2024-06-15 1:07 ` pinskia at gcc dot gnu.org
2024-06-21 22:42 ` andi-gcc at firstfloor dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-15 1:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Sam James from comment #2)
> GCC 8 vectorises it: https://godbolt.org/z/Y8Pvxsh5c.
The if-to-switch was not until GCC 11: r11-5605-g03eb09292ef228.
What made GCC 9 fail was the conversion from bool to int though:
/app/example.c:2:5: missed: not vectorized: relevant stmt not supported:
patt_29 = (int) patt_30;
But that worked in GCC 8. Though that was fixed in GCC 11.
If you replace `c|=` with:
```
c |= (*s == ',' | *s == '|' | *s == '!' | *s == '*');
```
GCC 11+ is able to vectorize it again. But the original testcase fails now due
to if-to-switch .
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
` (4 preceding siblings ...)
2024-06-15 1:06 ` pinskia at gcc dot gnu.org
@ 2024-06-15 1:07 ` pinskia at gcc dot gnu.org
2024-06-21 22:42 ` andi-gcc at firstfloor dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-15 1:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu.org
Target Milestone|--- |13.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/115484] [13/14/15 regression] if-to-switch prevents AVX vectorization
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
` (5 preceding siblings ...)
2024-06-15 1:07 ` pinskia at gcc dot gnu.org
@ 2024-06-21 22:42 ` andi-gcc at firstfloor dot org
6 siblings, 0 replies; 8+ messages in thread
From: andi-gcc at firstfloor dot org @ 2024-06-21 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115484
--- Comment #6 from Andi Kleen <andi-gcc at firstfloor dot org> ---
As an interesting but irrelevant side comment clang seems to have the same bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-06-21 22:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 4:14 [Bug tree-optimization/115484] New: AVX vectorization is limited to 3 comparisons andi-gcc at firstfloor dot org
2024-06-14 5:51 ` [Bug tree-optimization/115484] if-to-switch prevents AVX vectorization rguenth at gcc dot gnu.org
2024-06-15 0:54 ` [Bug tree-optimization/115484] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
2024-06-15 1:02 ` [Bug tree-optimization/115484] [13/14/15 " sjames at gcc dot gnu.org
2024-06-15 1:03 ` sjames at gcc dot gnu.org
2024-06-15 1:06 ` pinskia at gcc dot gnu.org
2024-06-15 1:07 ` pinskia at gcc dot gnu.org
2024-06-21 22:42 ` andi-gcc at firstfloor dot 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).