From: kub Date: Wed, 5 Jan 2022 22:41:24 +0000 (+0100) Subject: drc, tiny x86 optimisation X-Git-Tag: v2.00~381 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd184097221d29ec5cdf08ad2597a34066a6abe5;p=picodrive.git drc, tiny x86 optimisation --- 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 { \