public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109892] New: SLP failure with explicit fma
@ 2023-05-17 14:35 amonakov at gcc dot gnu.org
  2023-05-17 15:31 ` [Bug tree-optimization/109892] " pinskia at gcc dot gnu.org
  2023-05-17 19:43 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-05-17 14:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109892

            Bug ID: 109892
           Summary: SLP failure with explicit fma
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

At -O2 -mfma (x86) or -O3 (arm64) we fail to SLP-vectorize 'f', but succeed in
'g':

double f(double x[], long n)
{
    double r0 = 0, r1 = 0;
    for (; n; x += 2, n--) {
        r0 = __builtin_fma(x[0], x[0], r0);
        r1 = __builtin_fma(x[1], x[1], r1);
    }
    return r0 + r1;
}
static double muladd(double x, double y, double z)
{
    return x * y + z;
}
double g(double x[], long n)
{
    double r0 = 0, r1 = 0;
    for (; n; x += 2, n--) {
        r0 = muladd(x[0], x[0], r0);
        r1 = muladd(x[1], x[1], r1);
    }
    return r0 + r1;
}

It seems we are calling vectorizable_reduction for __builtin_fma even though it
would not participate in a reduction when vectorizing for 16-byte vectors?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/109892] SLP failure with explicit fma
  2023-05-17 14:35 [Bug tree-optimization/109892] New: SLP failure with explicit fma amonakov at gcc dot gnu.org
@ 2023-05-17 15:31 ` pinskia at gcc dot gnu.org
  2023-05-17 19:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17 15:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109892

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-17
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

I Notice that clang/LLVM does not vectorize the __builtin_fma either.

I also noticed for aarch64, GCC does not use faddp for the final reduction (but
I saw there was a patch submitted for that in 2021 but had not been updated for
the comments on it ...).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/109892] SLP failure with explicit fma
  2023-05-17 14:35 [Bug tree-optimization/109892] New: SLP failure with explicit fma amonakov at gcc dot gnu.org
  2023-05-17 15:31 ` [Bug tree-optimization/109892] " pinskia at gcc dot gnu.org
@ 2023-05-17 19:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-17 19:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109892

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |53947

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
x86 has no vector variant of the FMA builtin and/or we do not try the fma
vector optabs when seeing __builtin_fma.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-17 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 14:35 [Bug tree-optimization/109892] New: SLP failure with explicit fma amonakov at gcc dot gnu.org
2023-05-17 15:31 ` [Bug tree-optimization/109892] " pinskia at gcc dot gnu.org
2023-05-17 19:43 ` 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).