Skip to content

Commit

Permalink
JitArm64: divwx - Optimize division by 2
Browse files Browse the repository at this point in the history
...and let's optimize a divisor of 2 ever so slightly for
good measure. Most GameCube games seem to hit this on launch.
  • Loading branch information
JosJuice committed Aug 26, 2021
1 parent 9889e7e commit 91b112b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp
Expand Up @@ -1394,6 +1394,18 @@ void JitArm64::divwx(UGeckoInstruction inst)

gpr.Unlock(WA);
}
else if (divisor == 2 || divisor == -2)
{
ARM64Reg RA = gpr.R(a);
ARM64Reg RD = gpr.R(d);

ADD(RD, RA, RA, ArithOption(RA, ShiftType::LSR, 31));

if (divisor < 0)
NEG(RD, RD, ArithOption(RD, ShiftType::ASR, 1));
else
ASR(RD, RD, 1);
}
else if (MathUtil::IsPow2(divisor) || MathUtil::IsPow2(-static_cast<s64>(divisor)))
{
const u32 abs_val = static_cast<u32>(std::abs(static_cast<s64>(divisor)));
Expand Down

0 comments on commit 91b112b

Please sign in to comment.