JIT64: Optimize cmpXX

Use TEST instead of CMP if we're comparing against 0 (rather common), and
optimize the case of immediate compares further.
This commit is contained in:
Fiora 2014-08-24 11:24:27 -07:00
parent 41c3dde737
commit 61af91ff16
1 changed files with 20 additions and 4 deletions

View File

@ -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)