From: David Brown <david.brown@hesbynett.no>
To: gcc@gcc.gnu.org
Subject: Re: Who cares about performance (or Intel's CPU errata)?
Date: Sun, 28 May 2023 14:29:42 +0200 [thread overview]
Message-ID: <u4vhfm$msc$1@ciao.gmane.io> (raw)
In-Reply-To: <CA+=Sn1nPyYf8s9Z8QtL3n_mZyH3f+xg3o5icHKMkUn_VRezkbQ@mail.gmail.com>
On 28/05/2023 01:30, Andrew Pinski via Gcc wrote:
> On Sat, May 27, 2023 at 3:54 PM Stefan Kanthak <stefan.kanthak@nexgo.de> wrote:
>>
>> sete al
>> movzx eax, al # superfluous
>
> No it is not superfluous, well ok it is because of the context of eax
> (besides the lower 8 bits) are already zero'd but keeping that track
> is a hard problem and is turning problem really. And I suspect it
> would cause another false dependency later on too.
>
> For -Os -march=skylake (and -Oz instead of -Os) we get:
> popcnt rdi, rdi
> popcnt rsi, rsi
> add esi, edi
> xor eax, eax
> dec esi
> sete al
>
> Which is exactly what you want right?
>
> Thanks,
> Andrew
>
There is also the option of using "bool" as the return type for boolean
functions, rather than "int". When returning a "bool", gcc does not add
the "movzx eax, al" instruction. (There are some circumstances where
returning "int" for a boolean value is a better choice, but usually
"bool" makes more sense, and it can often be a touch more efficient.)
David
next prev parent reply other threads:[~2023-05-28 12:29 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
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 [this message]
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='u4vhfm$msc$1@ciao.gmane.io' \
--to=david.brown@hesbynett.no \
--cc=gcc@gcc.gnu.org \
/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).