summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2018-10-06 00:01:35 +0100
committerGitHub <noreply@github.com>2018-10-06 00:01:35 +0100
commit32ef8706e501542e09247831210dde75e3583ee7 (patch)
treebf65a2d49906197a94925f7120d79565b7a02808 /Source/Core
parentb480db9392800aadc8cb60f53d5c4725fd232100 (diff)
parent8a93dd01054f78be15d177e3578f7db0203a3241 (diff)
Merge pull request #7414 from Sintendo/shortmovs
x64Emitter: emit shorter MOVs for 64-bit immediates
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/x64Emitter.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/Source/Core/Common/x64Emitter.cpp b/Source/Core/Common/x64Emitter.cpp
index cc243810c1..f18ea9fd3a 100644
--- a/Source/Core/Common/x64Emitter.cpp
+++ b/Source/Core/Common/x64Emitter.cpp
@@ -1469,11 +1469,21 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
// mov reg64, imm64
else if (op == NormalOp::MOV)
{
- emit->Write8(0xB8 + (offsetOrBaseReg & 7));
- emit->Write64((u64)operand.offset);
- return;
+ // movabs reg64, imm64 (10 bytes)
+ if (static_cast<s64>(operand.offset) != static_cast<s32>(operand.offset))
+ {
+ emit->Write8(0xB8 + (offsetOrBaseReg & 7));
+ emit->Write64(operand.offset);
+ return;
+ }
+ // mov reg64, simm32 (7 bytes)
+ emit->Write8(op_def.imm32);
+ immToWrite = 32;
+ }
+ else
+ {
+ ASSERT_MSG(DYNA_REC, 0, "WriteNormalOp - Only MOV can take 64-bit imm");
}
- ASSERT_MSG(DYNA_REC, 0, "WriteNormalOp - Only MOV can take 64-bit imm");
}
else
{
@@ -1581,6 +1591,12 @@ 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<u32>(a2.offset))
+ {
+ WriteNormalOp(32, NormalOp::MOV, a1, a2.AsImm32());
+ return;
+ }
if (a1.IsSimpleReg() && a2.IsSimpleReg() && a1.GetSimpleReg() == a2.GetSimpleReg())
ERROR_LOG(DYNA_REC, "Redundant MOV @ %p - bug in JIT?", code);
WriteNormalOp(bits, NormalOp::MOV, a1, a2);