From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Subject: Re: [PATCH 1/3] target/mips: Use tcg_constant_tl() instead of tcg_gen_movi_tl()
Date: Fri, 4 Oct 2024 13:54:36 -0700 [thread overview]
Message-ID: <9b8c4a39-57c3-4143-b5c5-0abb271abbd1@linaro.org> (raw)
In-Reply-To: <20241004202621.4321-2-philmd@linaro.org>
On 10/4/24 13:26, Philippe Mathieu-Daudé wrote:
> @@ -11428,17 +11415,12 @@ static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,
> void gen_addiupc(DisasContext *ctx, int rx, int imm,
> int is_64_bit, int extended)
> {
> - TCGv t0;
> -
> if (extended && (ctx->hflags & MIPS_HFLAG_BMASK)) {
> gen_reserved_instruction(ctx);
> return;
> }
>
> - t0 = tcg_temp_new();
> -
> - tcg_gen_movi_tl(t0, pc_relative_pc(ctx));
> - tcg_gen_addi_tl(cpu_gpr[rx], t0, imm);
> + tcg_gen_addi_tl(cpu_gpr[rx], tcg_constant_tl(pc_relative_pc(ctx)), imm);
> if (!is_64_bit) {
> tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
> }
Oh dear. All of this can be computed during translate.
target_ulong val = pc_relative_pc(ctx) + imm;
if (!is_64_bit) {
val = (int32_t)val;
}
tcg_gen_movi_tl(cpu_gpr[rx], val);
> diff --git a/target/mips/tcg/micromips_translate.c.inc b/target/mips/tcg/micromips_translate.c.inc
> index 171508f7deb..d044592f83e 100644
> --- a/target/mips/tcg/micromips_translate.c.inc
> +++ b/target/mips/tcg/micromips_translate.c.inc
> @@ -980,8 +980,7 @@ static void gen_ldst_pair(DisasContext *ctx, uint32_t opc, int rd,
> tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_SL |
> ctx->default_tcg_memop_mask);
> gen_store_gpr(t1, rd);
> - tcg_gen_movi_tl(t1, 4);
> - gen_op_addr_add(ctx, t0, t0, t1);
> + gen_op_addr_add(ctx, t0, t0, tcg_constant_tl(4));
It might be useful to add a gen_op_addr_addi() helper.
Anyway, it's all an incremental improvement so,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2024-10-04 20:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 20:26 [PATCH 0/3] target: Use tcg_constant_tl() instead of tcg_gen_movi_tl() Philippe Mathieu-Daudé
2024-10-04 20:26 ` [PATCH 1/3] target/mips: " Philippe Mathieu-Daudé
2024-10-04 20:54 ` Richard Henderson [this message]
2024-10-04 20:26 ` [PATCH 2/3] target/tricore: " Philippe Mathieu-Daudé
2024-10-04 20:56 ` Richard Henderson
2024-10-04 20:26 ` [PATCH 3/3] target/ppc: " Philippe Mathieu-Daudé
2024-10-04 20:57 ` Richard Henderson
2024-10-15 14:53 ` [PATCH 0/3] target: " Philippe Mathieu-Daudé
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=9b8c4a39-57c3-4143-b5c5-0abb271abbd1@linaro.org \
--to=richard.henderson@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).