From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: Re: [PATCH 4/4] NOTFORMERGE tcg/i386: Assert sub of immediate has been folded
Date: Mon, 6 Nov 2023 15:49:29 +0100 [thread overview]
Message-ID: <ffe5e4b3-4c9a-9cee-f997-f53be1656b21@linaro.org> (raw)
In-Reply-To: <20231026013945.1152174-5-richard.henderson@linaro.org>
On 26/10/23 03:39, Richard Henderson wrote:
> A release build should simply accept and emit the subtract.
> I'm not even sure if this is reasonable to keep for debug.
>
> Not-Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> tcg/tcg.c | 49 ++++++++++++++++++++++++++-------------
> tcg/i386/tcg-target.c.inc | 13 ++++++++---
> 2 files changed, 43 insertions(+), 19 deletions(-)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index a507c111cf..408647af7e 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -3618,23 +3618,40 @@ liveness_pass_1(TCGContext *s)
> do_addsub2:
> nb_iargs = 4;
> nb_oargs = 2;
> - /* Test if the high part of the operation is dead, but not
> - the low part. The result can be optimized to a simple
> - add or sub. This happens often for x86_64 guest when the
> - cpu mode is set to 32 bit. */
> - if (arg_temp(op->args[1])->state == TS_DEAD) {
> - if (arg_temp(op->args[0])->state == TS_DEAD) {
> - goto do_remove;
> - }
> - /* Replace the opcode and adjust the args in place,
> - leaving 3 unused args at the end. */
> - op->opc = opc = opc_new;
> - op->args[1] = op->args[2];
> - op->args[2] = op->args[4];
> - /* Fall through and mark the single-word operation live. */
> - nb_iargs = 2;
> - nb_oargs = 1;
> + /*
> + * Test if the high part of the operation is dead, but the low
> + * part is still live. The result can be optimized to a simple
> + * add or sub.
> + */
> + if (arg_temp(op->args[1])->state != TS_DEAD) {
> + goto do_not_remove;
> }
> + if (arg_temp(op->args[0])->state == TS_DEAD) {
> + goto do_remove;
> + }
> + /*
> + * Replace the opcode and adjust the args in place, leaving 3
> + * unused args at the end. Canonicalize subi to andi.
Typo s/andi/addi/.
> + */
> + op->args[1] = op->args[2];
> + {
> + TCGTemp *src2 = arg_temp(op->args[4]);
> + if (src2->kind == TEMP_CONST) {
> + if (opc_new == INDEX_op_sub_i32) {
> + src2 = tcg_constant_internal(TCG_TYPE_I32,
> + (int32_t)-src2->val);
> + opc_new = INDEX_op_add_i32;
> + } else if (opc_new == INDEX_op_sub_i64) {
> + src2 = tcg_constant_internal(TCG_TYPE_I64, -src2->val);
> + opc_new = INDEX_op_add_i64;
> + }
> + }
> + op->args[2] = temp_arg(src2);
> + }
> + op->opc = opc = opc_new;
> + /* Mark the single-word operation live. */
> + nb_iargs = 2;
> + nb_oargs = 1;
> goto do_not_remove;
For tcg/tcg.c with your S-o-b and a reworded description:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2023-11-06 14:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 1:39 [PATCH 0/4] tcg: Canonicalize SUBI to ANDI Richard Henderson
2023-10-26 1:39 ` [PATCH 1/4] tcg: Canonicalize subi to addi during opcode generation Richard Henderson
2023-11-06 14:37 ` Philippe Mathieu-Daudé
2023-10-26 1:39 ` [PATCH 2/4] tcg/optimize: Canonicalize subi to addi during optimization Richard Henderson
2023-11-06 14:42 ` Philippe Mathieu-Daudé
2023-10-26 1:39 ` [PATCH 3/4] tcg/optimize: Canonicalize sub2 with constants to add2 Richard Henderson
2023-11-06 14:43 ` Philippe Mathieu-Daudé
2023-10-26 1:39 ` [PATCH 4/4] NOTFORMERGE tcg/i386: Assert sub of immediate has been folded Richard Henderson
2023-10-26 1:53 ` Richard Henderson
2023-11-06 14:49 ` Philippe Mathieu-Daudé [this message]
2023-10-31 22:20 ` [PATCH 0/4] tcg: Canonicalize SUBI to ANDI Richard Henderson
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=ffe5e4b3-4c9a-9cee-f997-f53be1656b21@linaro.org \
--to=philmd@linaro.org \
--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).