public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105451] New: miss optimizations due to inconsistency in complex numbers associativity
@ 2022-05-02 10:07 tnfchris at gcc dot gnu.org
2022-05-02 11:33 ` [Bug tree-optimization/105451] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-05-02 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105451
Bug ID: 105451
Summary: miss optimizations due to inconsistency in complex
numbers associativity
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: tnfchris at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
The two functions
#include <complex.h>
void f (complex double * restrict a, complex double *restrict b,
complex double *restrict c, complex double *res, int n)
{
for (int i = 0; i < n; i++)
res[i] = a[i] * (b[i] * c[i]);
}
and
void g (complex double * restrict a, complex double *restrict b,
complex double *restrict c, complex double *res, int n)
{
for (int i = 0; i < n; i++)
res[i] = (a[i] * b[i]) * c[i];
}
At -Ofast produce the same code, but internally they get there using different
SLP trees.
The former creates a chain of VEC_PERM_EXPR nodes as is expected
tinyurl.com/cmulslp1 however the latter avoids the need of the permutes by
duplicating the elements of the complex number https://tinyurl.com/cmulslp2
The former we can detect as back to back complex multiplication but the latter
we can't.
Not sure what the best way to get consistency here is.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/105451] miss optimizations due to inconsistency in complex numbers associativity
2022-05-02 10:07 [Bug tree-optimization/105451] New: miss optimizations due to inconsistency in complex numbers associativity tnfchris at gcc dot gnu.org
@ 2022-05-02 11:33 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-02 11:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105451
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-05-02
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's difficult to even spot the difference in the SLP tree, but the
associatable multiplications make it somewhat random which of the valid SLP
tree representations we'll pick. All of the SLP discovery is a heuristically
greedy search for the _first_ match, not for the "best" even ("best"
interpreted as "largest" in case of BB vectorization).
The only thing that reliably happens at the moment is associating until the
leafs are all from one load group (until we support multiple load groups in
one leaf).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-02 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 10:07 [Bug tree-optimization/105451] New: miss optimizations due to inconsistency in complex numbers associativity tnfchris at gcc dot gnu.org
2022-05-02 11:33 ` [Bug tree-optimization/105451] " rguenth 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).