public inbox for
 help / color / mirror / Atom feed
From: Alexander Monakov <>
To: Paul Zimmermann <>
Subject: Re: slowdown with -std=gnu18 with respect to -std=c99
Date: Tue, 3 May 2022 12:09:32 +0300 (MSK)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, 3 May 2022, Paul Zimmermann via Gcc-help wrote:

> Does anyone have a clue?

I can reproduce a difference, but in my case it's simply because in -std=gnuXX
mode (as opposed to -std=cXX) GCC enables FMA contraction, enabling the last few
steps in the benchmarked function to use fma instead of separate mul/add

(regarding __builtin_expect, it also makes a small difference in my case,
it seems GCC generates some redundant code without it, but the difference is
10x smaller than what presence/absence of FMA gives)

I think you might be able to figure it out on your end if you run both variants
under 'perf stat', note how cycle count and instruction counts change, and then
look at disassembly to see what changed. You can use 'perf record' and 'perf
report' to easily see the hot code path; if you do that, I'd recommend to run
it with the same sampling period in both cases, e.g. like this:

    perf record -e instructions:P -c 500000 ./perf ...


  reply	other threads:[~2022-05-03  9:09 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 [this message]
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
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:

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

  git send-email \ \ \ \ \ \ \

* 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).