From cd184097221d29ec5cdf08ad2597a34066a6abe5 Mon Sep 17 00:00:00 2001 From: kub Date: Wed, 5 Jan 2022 23:41:24 +0100 Subject: [PATCH] drc, tiny x86 optimisation --- cpu/drc/emit_x86.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cpu/drc/emit_x86.c b/cpu/drc/emit_x86.c index 94111e0f..3ef2ed62 100644 --- a/cpu/drc/emit_x86.c +++ b/cpu/drc/emit_x86.c @@ -519,15 +519,23 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI, // x86-64,i386 common // _r_r_imm - use lea #define emith_add_r_r_imm(d, s, imm) do { \ - EMIT_REX_IF(0, d, s); \ - emith_deref_modrm(0x8d, 2, d, s); \ - EMIT(imm, s32); \ + if (imm == 0) \ + emith_move_r_r(d, s); \ + else { \ + EMIT_REX_IF(0, d, s); \ + emith_deref_modrm(0x8d, 2, d, s); \ + EMIT(imm, s32); \ + } \ } while (0) #define emith_add_r_r_ptr_imm(d, s, imm) do { \ - EMIT_REX_IF(1, d, s); \ - emith_deref_modrm(0x8d, 2, d, s); \ - EMIT(imm, s32); \ + if (imm == 0) \ + emith_move_r_r_ptr(d, s); \ + else { \ + EMIT_REX_IF(1, d, s); \ + emith_deref_modrm(0x8d, 2, d, s); \ + EMIT(imm, s32); \ + } \ } while (0) #define emith_sub_r_r_imm(d, s, imm) do { \ -- 2.39.5