From 61af91ff163468cd9d99a9229001f614155ecc1e Mon Sep 17 00:00:00 2001 From: Fiora Date: Sun, 24 Aug 2014 11:24:27 -0700 Subject: [PATCH] JIT64: Optimize cmpXX Use TEST instead of CMP if we're comparing against 0 (rather common), and optimize the case of immediate compares further. --- .../Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 8398a5e97c..1d43d2b406 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -479,13 +479,29 @@ void Jit64::cmpXX(UGeckoInstruction inst) MOVZX(64, 32, RAX, gpr.R(a)); if (comparand.IsImm()) - MOV(32, R(ABI_PARAM1), comparand); + { + // sign extension will ruin this, so store it in a register + if (comparand.offset & 0x80000000U) + { + MOV(32, R(ABI_PARAM1), comparand); + comparand = R(ABI_PARAM1); + } + } else + { MOVZX(64, 32, ABI_PARAM1, comparand); - - comparand = R(ABI_PARAM1); + comparand = R(ABI_PARAM1); + } + } + if (comparand.IsImm() && !comparand.offset) + { + if (merge_branch) + TEST(64, R(RAX), R(RAX)); + } + else + { + SUB(64, R(RAX), comparand); } - SUB(64, R(RAX), comparand); MOV(64, M(&PowerPC::ppcState.cr_val[crf]), R(RAX)); if (merge_branch)