public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/116475] New: autovect: may be optimized for min/max
@ 2024-08-24 4:36 syq at gcc dot gnu.org
2024-08-24 4:55 ` [Bug tree-optimization/116475] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: syq at gcc dot gnu.org @ 2024-08-24 4:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116475
Bug ID: 116475
Summary: autovect: may be optimized for min/max
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: syq at gcc dot gnu.org
Target Milestone: ---
If we need get the minimal of 8 floats in an array.
We may have code like this
float min(float *x) {
float ret = x[0];
for (int i=0; i<8; i++) { // from 0 in this line
ret = ret<x[i] ? ret : x[i];
}
return ret;
}
While if we compile it with
aarch64-linux-gnu-gcc -O3 -ffast-math -S xx.c
We get
ldp q0, q1, [x0]
ld1r {v31.4s}, [x0] # <-- not needed
fminnm v31.4s, v1.4s, v31.4s # <-- not needed
fminnm v0.4s, v31.4s, v0.4s
fminnmv s0, v0.4s
ret
And maybe we can also use
float min(float *x) {
float ret = x[0];
for (int i=1; i<8; i++) { // from 1 in this line
ret = ret<x[i] ? ret : x[i];
}
return ret;
}
It will be even worse
ldr q31, [x0, 4]
ld1r {v30.4s}, [x0]
ldp s0, s29, [x0, 20]
fminnm v31.4s, v31.4s, v30.4s
ldr s30, [x0, 28]
fminnm s0, s0, s29
fminnmv s31, v31.4s
fminnm s31, s30, s31
fminnm s0, s0, s31
ret
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/116475] autovect: may be optimized for min/max
2024-08-24 4:36 [Bug tree-optimization/116475] New: autovect: may be optimized for min/max syq at gcc dot gnu.org
@ 2024-08-24 4:55 ` pinskia at gcc dot gnu.org
2024-08-24 4:55 ` pinskia at gcc dot gnu.org
2024-08-24 4:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-24 4:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116475
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |53947
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I thought I saw this before.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/116475] autovect: may be optimized for min/max
2024-08-24 4:36 [Bug tree-optimization/116475] New: autovect: may be optimized for min/max syq at gcc dot gnu.org
2024-08-24 4:55 ` [Bug tree-optimization/116475] " pinskia at gcc dot gnu.org
@ 2024-08-24 4:55 ` pinskia at gcc dot gnu.org
2024-08-24 4:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-24 4:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116475
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/116475] autovect: may be optimized for min/max
2024-08-24 4:36 [Bug tree-optimization/116475] New: autovect: may be optimized for min/max syq at gcc dot gnu.org
2024-08-24 4:55 ` [Bug tree-optimization/116475] " pinskia at gcc dot gnu.org
2024-08-24 4:55 ` pinskia at gcc dot gnu.org
@ 2024-08-24 4:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-24 4:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116475
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yep pr 102512
*** This bug has been marked as a duplicate of bug 102512 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-24 4:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-24 4:36 [Bug tree-optimization/116475] New: autovect: may be optimized for min/max syq at gcc dot gnu.org
2024-08-24 4:55 ` [Bug tree-optimization/116475] " pinskia at gcc dot gnu.org
2024-08-24 4:55 ` pinskia at gcc dot gnu.org
2024-08-24 4:57 ` pinskia 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).