From: Alexander Monakov <amonakov@ispras.ru>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
qemu-devel@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: Re: [PATCH 0/5] Reinstate ability to use Qemu on pre-SSE4.1 x86 hosts
Date: Wed, 12 Jun 2024 14:46:01 +0300 (MSK) [thread overview]
Message-ID: <caa7d068-a2c6-28a4-51d5-93c61f004bc0@ispras.ru> (raw)
In-Reply-To: <CABgObfYf8=3yXu1p6q6jzyZ7uHy92BHaBXtJY8AMYXBdd9+HGA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]
On Wed, 12 Jun 2024, Paolo Bonzini wrote:
> On Wed, Jun 12, 2024 at 1:19 PM Alexander Monakov <amonakov@ispras.ru> wrote:
> > On Wed, 12 Jun 2024, Paolo Bonzini wrote:
> > > I didn't do this because of RHEL9, I did it because it's silly that
> > > QEMU cannot use POPCNT and has to waste 2% of the L1 d-cache to
> > > compute the x86 parity flag (and POPCNT was introduced at the same
> > > time as SSE4.2).
> >
> > From looking at that POPCNT patch I understood that Qemu detects
> > presence of POPCNT at runtime and will only use the fallback when
> > POPCNT is unavailable. Did I misunderstand?
>
> -mpopcnt allows GCC to generate the POPCNT instruction for helper
> code. Right now we have code like this in
> target/i386/tcg/cc_helper_template.h:
>
> pf = parity_table[(uint8_t)dst];
>
> and it could be instead something like
>
> #if defined __i386__ || defined __x86_64__ || defined __s390x__||
> defined __riscv_zbb
GCC also predefines __POPCNT__ when -mpopcnt is active, so that would be
available for ifdef testing like above, but...
> static inline unsigned int compute_pf(uint8_t x)
> {
> return __builtin_parity(x) * CC_P;
> }
> #else
> extern const uint8_t parity_table[256];
> static inline unsigned int compute_pf(uint8_t x)
> {
> return parity_table[x];
> }
> #endif
>
> The code generated for __builtin_parity, if you don't have it
> available in hardware, is pretty bad.
On x86 parity _is_ available in baseline ISA, no? Here's what gcc-14 generates:
xor eax, eax
test dil, dil
setnp al
sal eax, 2
and with -mpopcnt:
movsx eax, dil
popcnt eax, eax
and eax, 1
sal eax, 2
Alexander
next prev parent reply other threads:[~2024-06-12 11:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 10:55 [PATCH 0/5] Reinstate ability to use Qemu on pre-SSE4.1 x86 hosts Alexander Monakov
2024-06-12 10:55 ` [PATCH 1/5] Revert "host/i386: assume presence of POPCNT" Alexander Monakov
2024-06-12 10:55 ` [PATCH 2/5] Revert "host/i386: assume presence of SSSE3" Alexander Monakov
2024-06-12 10:55 ` [PATCH 3/5] Revert "host/i386: assume presence of SSE2" Alexander Monakov
2024-06-12 10:55 ` [PATCH 4/5] Revert "host/i386: assume presence of CMOV" Alexander Monakov
2024-06-12 10:55 ` [PATCH 5/5] Revert "meson: assume x86-64-v2 baseline ISA" Alexander Monakov
2024-06-12 11:04 ` [PATCH 0/5] Reinstate ability to use Qemu on pre-SSE4.1 x86 hosts Daniel P. Berrangé
2024-06-12 11:12 ` Paolo Bonzini
2024-06-12 11:19 ` Alexander Monakov
2024-06-12 11:29 ` Paolo Bonzini
2024-06-12 11:46 ` Alexander Monakov [this message]
2024-06-12 11:58 ` Paolo Bonzini
2024-06-12 12:10 ` Alexander Monakov
2024-06-12 12:13 ` Paolo Bonzini
2024-06-12 13:34 ` Alexander Monakov
2024-06-12 13:39 ` Paolo Bonzini
2024-06-12 14:27 ` Alexander Monakov
2024-06-12 11:38 ` Daniel P. Berrangé
2024-06-12 11:51 ` Paolo Bonzini
2024-06-12 12:21 ` Daniel P. Berrangé
2024-06-12 15:09 ` Daniel P. Berrangé
2024-06-12 15:29 ` Paolo Bonzini
2024-06-12 15:40 ` Alexander Monakov
2024-06-12 16:24 ` Daniel P. Berrangé
2024-06-12 17:06 ` Daniel P. Berrangé
2024-06-12 17:00 ` Daniel P. Berrangé
2024-06-12 17:08 ` Paolo Bonzini
2024-06-23 21:27 ` Alexander Monakov
2024-06-23 22:14 ` Richard Henderson
2024-06-12 11:14 ` Alexander Monakov
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=caa7d068-a2c6-28a4-51d5-93c61f004bc0@ispras.ru \
--to=amonakov@ispras.ru \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 NNTP newsgroup(s).