public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Stefan Kanthak <stefan.kanthak@nexgo.de>
Cc: gcc@gnu.org
Subject: Re: Who cares about performance (or Intel's CPU errata)?
Date: Sat, 27 May 2023 14:47:52 -0700	[thread overview]
Message-ID: <CA+=Sn1nrDBd-LN-rY0E=a4Q_kRu5E0Gh4n-THjxhgvn3n2m0pQ@mail.gmail.com> (raw)
In-Reply-To: <23A490318B7149D88618A7CDA2CEDB14@H270>

On Sat, May 27, 2023 at 2:25 PM Stefan Kanthak <stefan.kanthak@nexgo.de> wrote:
>
> Just to show how SLOPPY, INCONSEQUENTIAL and INCOMPETENT GCC's developers are:
>
> --- dontcare.c ---
> int ispowerof2(unsigned __int128 argument) {
>     return __builtin_popcountll(argument) + __builtin_popcountll(argument >> 64) == 1;
> }
> --- EOF ---
>
> GCC 13.3    gcc -march=haswell -O3
>
> https://gcc.godbolt.org/z/PPzYsPzMc
> ispowerof2(unsigned __int128):
>         popcnt  rdi, rdi
>         popcnt  rsi, rsi
>         add     esi, edi
>         xor     eax, eax
>         cmp     esi, 1
>         sete    al
>         ret
>
> OOPS: what about Intel's CPU errata regarding the false dependency on POPCNTs output?

Because the popcount is going to the same register, there is no false
dependency ....
The false dependency errata only applies if the result of the popcnt
is going to a different register, the processor thinks it depends on
the result in that register from a previous instruction but it does
not (which is why it is called a false dependency). In this case it
actually does depend on the previous result since the input is the
same as the input.

Thanks,
Andrew

>
> See https://gcc.godbolt.org/z/jdjTc3EET for comparison!
>
> FIX YOUR BUGS, KIDS!
>
> Stefan

  reply	other threads:[~2023-05-27 21:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27 21:20 Stefan Kanthak
2023-05-27 21:47 ` Andrew Pinski [this message]
2023-05-27 22:52   ` Stefan Kanthak
2023-05-27 23:18     ` Mark Wielaard
2023-05-27 23:30     ` Andrew Pinski
2023-05-28  7:47       ` Stefan Kanthak
2023-05-28 12:29       ` David Brown
2023-05-29 18:11       ` Who cares about size? (was: Who cares about performance (or Intel's CPU errata)?) Stefan Kanthak
2023-05-28  6:40     ` Who cares about performance (or Intel's CPU errata)? Nicholas Vinson

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='CA+=Sn1nrDBd-LN-rY0E=a4Q_kRu5E0Gh4n-THjxhgvn3n2m0pQ@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=gcc@gnu.org \
    --cc=stefan.kanthak@nexgo.de \
    /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).