Commit 625ceed816 for qemu.org
commit 625ceed8167b13a7e887df191ffb653e0009ae1d
Author: Richard Henderson <richard.henderson@linaro.org>
Date: Fri Aug 28 05:48:58 2026 -0700
target/i386: Use tcg_gen_lea_tl in gen_lea_modrm_1
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index dd417cb534..5199c330ac 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -1698,31 +1698,32 @@ static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp ot,
/* Compute the address, with a minimum number of TCG ops. */
static TCGv gen_lea_modrm_1(DisasContext *s, AddressParts a, bool is_vsib)
{
- TCGv ea = NULL;
+ TCGv ea = (a.base >= 0 ? cpu_regs[a.base] : NULL);
if (a.index >= 0 && !is_vsib) {
+ TCGv index = cpu_regs[a.index];
+
+ if (ea) {
+ tcg_gen_lea_tl(s->A0, ea, index, a.scale, a.disp);
+ return s->A0;
+ }
if (a.scale == 0) {
- ea = cpu_regs[a.index];
+ ea = index;
} else {
- tcg_gen_shli_tl(s->A0, cpu_regs[a.index], a.scale);
- ea = s->A0;
- }
- if (a.base >= 0) {
- tcg_gen_add_tl(s->A0, ea, cpu_regs[a.base]);
+ tcg_gen_shli_tl(s->A0, index, a.scale);
ea = s->A0;
}
- } else if (a.base >= 0) {
- ea = cpu_regs[a.base];
- }
- if (!ea) {
+ } else if (!ea) {
if (tb_cflags(s->base.tb) & CF_PCREL && a.base == -2) {
/* With cpu_eip ~= pc_save, the expression is pc-relative. */
tcg_gen_addi_tl(s->A0, cpu_eip, a.disp - s->pc_save);
} else {
tcg_gen_movi_tl(s->A0, a.disp);
}
- ea = s->A0;
- } else if (a.disp != 0) {
+ return s->A0;
+ }
+
+ if (a.disp != 0) {
tcg_gen_addi_tl(s->A0, ea, a.disp);
ea = s->A0;
}