public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/97147] New: GCC uses vhaddpd which is bad for latency
@ 2020-09-21 12:56 rguenth at gcc dot gnu.org
  2020-09-22  6:43 ` [Bug target/97147] " crazylht at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-21 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97147
           Summary: GCC uses vhaddpd which is bad for latency
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

typedef double v2df __attribute__((vector_size(16)));
double foo (v2df x, double y)
{
  return x[0] + x[1] + y;
}
double bar (v2df x, double y)
{
  return y + x[0] + x[1];
}

with -O2 -mavx2 -mtune=znver2 ends up generating

foo:
.LFB0:
        .cfi_startproc
        vhaddpd %xmm0, %xmm0, %xmm0
        vaddsd  %xmm1, %xmm0, %xmm0
        ret

bar:
.LFB1:
        .cfi_startproc
        vmovapd %xmm0, %xmm2
        vaddsd  %xmm1, %xmm0, %xmm0
        vunpckhpd       %xmm2, %xmm2, %xmm2
        vaddsd  %xmm2, %xmm0, %xmm0
        ret

where bar should be a _lot_ better according to Agner which says
that vhaddpd has a 4 uops, a latency of 7 cycles and a throughput of only
one per two cycles while both vunpckhpd and vaddsd fare a lot better here.
Coffee-lake isn't much better here.

Maybe we want to disable the V2DF instructions for most tunings somehow?

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

end of thread, other threads:[~2022-01-11 12:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 12:56 [Bug target/97147] New: GCC uses vhaddpd which is bad for latency rguenth at gcc dot gnu.org
2020-09-22  6:43 ` [Bug target/97147] " crazylht at gmail dot com
2021-08-17  3:03 ` crazylht at gmail dot com
2021-08-17  6:58 ` rguenth at gcc dot gnu.org
2021-08-17  7:17 ` crazylht at gmail dot com
2021-08-17  7:36 ` rguenther at suse dot de
2021-08-18  3:26 ` cvs-commit at gcc dot gnu.org
2021-08-18  3:27 ` crazylht at gmail dot com
2022-01-11 12:07 ` 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).