Skip to content

Commit

Permalink
Merge pull request #9817 from Sintendo/jit64subfic
Browse files Browse the repository at this point in the history
Jit64: subfic - Optimize constants for d != a
  • Loading branch information
degasus committed Jun 17, 2021
2 parents 4e9e75f + 18aaf48 commit b530d9b
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp
Expand Up @@ -898,28 +898,31 @@ void Jit64::subfic(UGeckoInstruction inst)
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rd);

if (d == a)
if (imm == 0)
{
if (imm == 0)
{
// Flags act exactly like subtracting from 0
NEG(32, Rd);
// Output carry is inverted
FinalizeCarry(CC_NC);
}
else if (imm == -1)
{
NOT(32, Rd);
// CA is always set in this case
FinalizeCarry(true);
}
else
{
NOT(32, Rd);
ADD(32, Rd, Imm32(imm + 1));
// Output carry is normal
FinalizeCarry(CC_C);
}
if (d != a)
MOV(32, Rd, Ra);

// Flags act exactly like subtracting from 0
NEG(32, Rd);
// Output carry is inverted
FinalizeCarry(CC_NC);
}
else if (imm == -1)
{
if (d != a)
MOV(32, Rd, Ra);

NOT(32, Rd);
// CA is always set in this case
FinalizeCarry(true);
}
else if (d == a)
{
NOT(32, Rd);
ADD(32, Rd, Imm32(imm + 1));
// Output carry is normal
FinalizeCarry(CC_C);
}
else
{
Expand Down

0 comments on commit b530d9b

Please sign in to comment.