public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Cc: gcc-help@gcc.gnu.org, stephane.glondu@inria.fr,
	marc.glisse@inria.fr,  sibid@uvic.ca
Subject: Re: slowdown with -std=gnu18 with respect to -std=c99
Date: Wed, 11 May 2022 16:26:05 +0300 (MSK)	[thread overview]
Message-ID: <9b56647e-46bb-9a79-d9a0-439e2f35ee27@ispras.ru> (raw)
In-Reply-To: <2b4e81-fee-e79-5ea0-bf658f20b4c2@ispras.ru>

On Fri, 6 May 2022, Alexander Monakov wrote:

> The primary issue here is false dependency on vcvtss2sd instruction. In the
> snippet shown in Stéphane's email, the slower variant begins with
> 
>     vcvtss2sd   -0x4(%rsp),%xmm1,%xmm1
> 
> The cvtss2sd instruction is specified to take the upper bits of SSE register
> unmodified, so here it merges high bits of xmm1 with results of float->double
> conversion (in low bits) into new xmm1. Unless the CPU can track dependencies
> separately for vector register components, it has to delay this instruction
> until the previous computation that modified xmm1 has completed (AMD Zen2 is
> an example of a microarchitecture that apparently can).

For future reference, my statement in parenthesis was a bit inaccurate: Zen 2
avoids the false dependency provided that xmm1 carries all-zeroes in high bits
after being idiomatically zeroed (i.e. via pxor). Thanks to Andreas Abel for
pointing out there's a limitation.

(nevertheless, the "blessed" state seemingly survives context switches, so
it's quite useful, including this testcase)

Alexander

  parent reply	other threads:[~2022-05-11 13:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03  8:28 Paul Zimmermann
2022-05-03  9:09 ` Alexander Monakov
2022-05-03 11:45   ` Paul Zimmermann
2022-05-03 12:12     ` Alexander Monakov
2022-05-05  8:57   ` Stéphane Glondu
2022-05-05 14:31     ` Stéphane Glondu
2022-05-05 14:41       ` Marc Glisse
2022-05-05 14:56         ` Alexander Monakov
2022-05-06  7:46           ` Paul Zimmermann
2022-05-06  9:27             ` Alexander Monakov
2022-05-07  6:11               ` Paul Zimmermann
2022-05-11 13:26               ` Alexander Monakov [this message]
2022-05-05 17:50         ` Paul Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b56647e-46bb-9a79-d9a0-439e2f35ee27@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=Paul.Zimmermann@inria.fr \
    --cc=gcc-help@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    --cc=sibid@uvic.ca \
    --cc=stephane.glondu@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).