From: Richard Henderson <richard.henderson@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] tcg/i386: convert add/sub of 128 to sub/add of -128
Date: Thu, 28 Dec 2023 07:13:14 +1100 [thread overview]
Message-ID: <1110c99f-b441-4c64-9cf5-2a863a14f059@linaro.org> (raw)
In-Reply-To: <20231221134355.35304-1-pbonzini@redhat.com>
On 12/22/23 00:43, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> tcg/i386/tcg-target.c.inc | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
> index a83f8aab304..4e9f372d4fd 100644
> --- a/tcg/i386/tcg-target.c.inc
> +++ b/tcg/i386/tcg-target.c.inc
> @@ -1332,7 +1332,11 @@ static void tgen_arithi(TCGContext *s, int c, int r0,
> return;
> }
>
> - if (c == ARITH_AND) {
> + if ((c == ARITH_ADD || c == ARITH_SUB) && val == 128) {
> + /* Facilitate using an 8-bit immediate. */
> + c ^= ARITH_ADD ^ ARITH_SUB;
> + val = -128;
> + } else if (c == ARITH_AND) {
> if (TCG_TARGET_REG_BITS == 64) {
> if (val == 0xffffffffu) {
> tcg_out_ext32u(s, r0, r0);
Need to check for !cf, because this swaps the sense of carry.
Ought to merge this with the inc/dec block above to save comparisons.
r~
prev parent reply other threads:[~2023-12-27 20:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 13:43 [PATCH] tcg/i386: convert add/sub of 128 to sub/add of -128 Paolo Bonzini
2023-12-27 20:13 ` Richard Henderson [this message]
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=1110c99f-b441-4c64-9cf5-2a863a14f059@linaro.org \
--to=richard.henderson@linaro.org \
--cc=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).