From ce1052505684afbfe7cbdd564fd81ca0aeda863b Mon Sep 17 00:00:00 2001 From: Sintendo Date: Sun, 5 Jul 2015 11:18:59 +0200 Subject: [PATCH] Eliminate branch in GenFres --- .../Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp index 64adf9b4de..b0f38ca1ec 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp @@ -119,13 +119,12 @@ void CommonAsmRoutines::GenFres() MOV(32, R(RSCRATCH2), R(RSCRATCH_EXTRA)); AND(32, R(RSCRATCH_EXTRA), Imm32(0x7FF)); // exp AND(32, R(RSCRATCH2), Imm32(0x800)); // sign - CMP(32, R(RSCRATCH_EXTRA), Imm32(895)); + SUB(32, R(RSCRATCH_EXTRA), Imm32(895)); + CMP(32, R(RSCRATCH_EXTRA), Imm32(1149 - 895)); // Take the complex path for very large/small exponents. - FixupBranch complex1 = J_CC(CC_L); - CMP(32, R(RSCRATCH_EXTRA), Imm32(1149)); - FixupBranch complex2 = J_CC(CC_GE); + FixupBranch complex = J_CC(CC_AE); // if (exp < 895 || exp >= 1149) - SUB(32, R(RSCRATCH_EXTRA), Imm32(0x7FD)); + SUB(32, R(RSCRATCH_EXTRA), Imm32(0x7FD - 895)); NEG(32, R(RSCRATCH_EXTRA)); OR(32, R(RSCRATCH_EXTRA), R(RSCRATCH2)); SHL(64, R(RSCRATCH_EXTRA), Imm8(52)); // vali = sign | exponent @@ -154,8 +153,7 @@ void CommonAsmRoutines::GenFres() OR(32, PPCSTATE(fpscr), Imm32(FPSCR_FX | FPSCR_ZX)); SetJumpTarget(skip_set_fx1); - SetJumpTarget(complex1); - SetJumpTarget(complex2); + SetJumpTarget(complex); ABI_PushRegistersAndAdjustStack(QUANTIZED_REGS_TO_SAVE, 8); ABI_CallFunction((void *)&MathUtil::ApproximateReciprocal); ABI_PopRegistersAndAdjustStack(QUANTIZED_REGS_TO_SAVE, 8);