From c84f34bd500bbf201b68ae8520f3b3039d2f3f50 Mon Sep 17 00:00:00 2001 From: Sintendo Date: Wed, 29 May 2019 00:47:12 +0200 Subject: [PATCH] x64Emitter: Short MOVs for 32bit immediates Prior to this commit, the emitter would emit a 7-byte instruction when loading a 32-bit immediate to a 64-bit register. 0: 48 c7 c0 ff ff ff 7f mov rax,0x7fffffff With this change, it will check if it can instead emit a load to a 32-bit register, which takes only 5 or 6 bytes. 0: b8 ff ff ff 7f mov eax,0x7fffffff --- Source/Core/Common/x64Emitter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/x64Emitter.cpp b/Source/Core/Common/x64Emitter.cpp index 63c094ad6f..947e6e5614 100644 --- a/Source/Core/Common/x64Emitter.cpp +++ b/Source/Core/Common/x64Emitter.cpp @@ -1591,8 +1591,9 @@ void XEmitter::XOR(int bits, const OpArg& a1, const OpArg& a2) } void XEmitter::MOV(int bits, const OpArg& a1, const OpArg& a2) { - if (bits == 64 && a1.IsSimpleReg() && a2.scale == SCALE_IMM64 && - a2.offset == static_cast(a2.offset)) + if (bits == 64 && a1.IsSimpleReg() && + ((a2.scale == SCALE_IMM64 && a2.offset == static_cast(a2.offset)) || + (a2.scale == SCALE_IMM32 && static_cast(a2.offset) >= 0))) { WriteNormalOp(32, NormalOp::MOV, a1, a2.AsImm32()); return;