summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2015-04-23 16:34:23 -0400
committercomex <comexk@gmail.com>2015-04-23 16:34:23 -0400
commitb3aaa46d42a8236cfb0ac985378ded8392b29cee (patch)
tree7646e2d5dbb396bf8ff5db13291b63c757c41cec /Source/Core/Common
parente4b5637c3ac997de162a5fd08a36b4b787cb54d8 (diff)
parentc19482c9a39f420b769ba9386bd4254fbcb309b9 (diff)
Merge pull request #2088 from Sintendo/diecmp
Emit 'TEST reg, reg' for 'CMP reg, 0' automatically
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/x64Emitter.cpp12
-rw-r--r--Source/Core/Common/x64Emitter.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/Source/Core/Common/x64Emitter.cpp b/Source/Core/Common/x64Emitter.cpp
index 277443efca..0219f9798a 100644
--- a/Source/Core/Common/x64Emitter.cpp
+++ b/Source/Core/Common/x64Emitter.cpp
@@ -1274,6 +1274,18 @@ void XEmitter::MOV (int bits, const OpArg &a1, const OpArg &a2)
void XEmitter::TEST(int bits, const OpArg &a1, const OpArg &a2) {CheckFlags(); WriteNormalOp(bits, nrmTEST, a1, a2);}
void XEmitter::CMP (int bits, const OpArg &a1, const OpArg &a2) {CheckFlags(); WriteNormalOp(bits, nrmCMP, a1, a2);}
void XEmitter::XCHG(int bits, const OpArg &a1, const OpArg &a2) {WriteNormalOp(bits, nrmXCHG, a1, a2);}
+void XEmitter::CMP_or_TEST(int bits, const OpArg &a1, const OpArg &a2)
+{
+ CheckFlags();
+ if (a1.IsSimpleReg() && a2.IsImm() && a2.offset == 0) // turn 'CMP reg, 0' into shorter 'TEST reg, reg'
+ {
+ WriteNormalOp(bits, nrmTEST, a1, a1);
+ }
+ else
+ {
+ WriteNormalOp(bits, nrmCMP, a1, a2);
+ }
+}
void XEmitter::IMUL(int bits, X64Reg regOp, OpArg a1, OpArg a2)
{
diff --git a/Source/Core/Common/x64Emitter.h b/Source/Core/Common/x64Emitter.h
index c726fa6cbc..a1bc0301d1 100644
--- a/Source/Core/Common/x64Emitter.h
+++ b/Source/Core/Common/x64Emitter.h
@@ -484,6 +484,8 @@ public:
void MOV (int bits, const OpArg &a1, const OpArg &a2);
void TEST(int bits, const OpArg &a1, const OpArg &a2);
+ void CMP_or_TEST(int bits, const OpArg &a1, const OpArg &a2);
+
// Are these useful at all? Consider removing.
void XCHG(int bits, const OpArg &a1, const OpArg &a2);
void XCHG_AHAL();