From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [CFT PATCH 00/14] Improve handling of x86 condition codes (tcg)
Date: Sat, 6 Oct 2012 14:30:07 +0200 [thread overview]
Message-ID: <1349526621-13939-1-git-send-email-pbonzini@redhat.com> (raw)
So I was curious about TCG and bored at the same time. :)
This series achieves 2-6% improvements in all the three benchmarks that I
tried ("dc -e10000k1000vp", 1500 digits of pi with bc, SHA-1 of 100 MB
of random data), so it must not be that bad.
It improves all three aspects of handling x86 condition codes: the good,
the bad, and the ugly.
The good is the things that are fast. This series makes more things fast.
ZF, SF, CF and PF can be computed using TCG ops most of the time, while
remaining lazy. They are cheap, so repeated computation is not a problem.
Only computations that require the overflow flag need the compute_eflags
helper. Jumps whose result is computed in a previous basic block also
do, but even this could be eliminated in a future patch for ZF/SF/PF.
The bad is the things that are slow. After this series QEMU does slow
things less. The result of the compute_eflags helper is cached, because
the CC_OP_EFLAGS state can produce just as fast code as the specialized
states---the only cost is setting it up the first time EFLAGS is needed,
and that's unavoidable.
The ugly is the things that are rare. This series may make rare things
slower, but at the same it makes them simpler. For example shifts result
in a CC_OP_EFLAGS state instead of CC_OP_DYNAMIC. This may result
in an extra call to compute EFLAGS, but at the same time exposes more
optimization opportunities downstream.
I won't really have time to look at this further, but there is more
low-hanging fruit. Implementing (and using) movcond should be easier
after this series for example. I'm looking at you, Richard...
If anybody can help testing it less cursorily than I did, that would be
great.
Paolo
Paolo Bonzini (14):
i386: use OT_* consistently
i386: introduce gen_ext_tl
i386: factor setting of s->cc_op handling for string functions
i386: drop cc_op argument of gen_jcc1
i386: move eflags computation closer to gen_op_set_cc_op
i386: factor gen_op_set_cc_op/tcg_gen_discard_tl around computing flags
i386: add helper functions to get other flags
i386: do not compute eflags multiple times consecutively
i386: do not call helper to compute ZF/SF
i386: use inverted setcond when computing NS or NZ
i386: convert gen_compute_eflags_c to TCG
i386: change gen_setcc_slow_T0 to gen_setcc_slow
i386: optimize setbe
i386: optimize setcc instructions
target-i386/cc_helper.c | 118 -------
target-i386/cc_helper_template.h | 76 -----
target-i386/helper.h | 1 -
target-i386/translate.c | 691 +++++++++++++++++++++------------------
4 file modificati, 365 inserzioni(+), 521 rimozioni(-)
--
1.7.12.1
next reply other threads:[~2012-10-06 12:30 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-06 12:30 Paolo Bonzini [this message]
2012-10-06 12:30 ` [Qemu-devel] [PATCH 01/14] i386: use OT_* consistently Paolo Bonzini
2012-10-07 18:50 ` Blue Swirl
2012-10-09 18:58 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 02/14] i386: introduce gen_ext_tl Paolo Bonzini
2012-10-07 18:53 ` Blue Swirl
2012-10-09 18:58 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 03/14] i386: factor setting of s->cc_op handling for string functions Paolo Bonzini
2012-10-09 18:59 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 04/14] i386: drop cc_op argument of gen_jcc1 Paolo Bonzini
2012-10-09 18:59 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 05/14] i386: move eflags computation closer to gen_op_set_cc_op Paolo Bonzini
2012-10-09 19:02 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 06/14] i386: factor gen_op_set_cc_op/tcg_gen_discard_tl around computing flags Paolo Bonzini
2012-10-09 19:03 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 07/14] i386: add helper functions to get other flags Paolo Bonzini
2012-10-07 19:04 ` Blue Swirl
2012-10-09 19:04 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 08/14] i386: do not compute eflags multiple times consecutively Paolo Bonzini
2012-10-07 19:09 ` Blue Swirl
2012-10-09 19:14 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 09/14] i386: do not call helper to compute ZF/SF Paolo Bonzini
2012-10-07 19:16 ` Blue Swirl
2012-10-09 19:15 ` Richard Henderson
2012-10-09 19:16 ` Richard Henderson
2012-10-10 6:42 ` Paolo Bonzini
2012-10-06 12:30 ` [Qemu-devel] [PATCH 10/14] i386: use inverted setcond when computing NS or NZ Paolo Bonzini
2012-10-07 19:19 ` Blue Swirl
2012-10-09 19:17 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 11/14] i386: convert gen_compute_eflags_c to TCG Paolo Bonzini
2012-10-07 19:35 ` Blue Swirl
2012-10-09 20:07 ` Richard Henderson
2012-10-10 6:47 ` Paolo Bonzini
2012-10-06 12:30 ` [Qemu-devel] [PATCH 12/14] i386: change gen_setcc_slow_T0 to gen_setcc_slow Paolo Bonzini
2012-10-07 19:36 ` Blue Swirl
2012-10-09 20:07 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 13/14] i386: optimize setbe Paolo Bonzini
2012-10-07 19:43 ` Blue Swirl
2012-10-09 20:13 ` Richard Henderson
2012-10-06 12:30 ` [Qemu-devel] [PATCH 14/14] i386: optimize setcc instructions Paolo Bonzini
2012-10-07 19:58 ` Blue Swirl
2012-10-09 20:22 ` Richard Henderson
2012-10-10 6:51 ` Paolo Bonzini
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=1349526621-13939-1-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).