srawx/srawix optimizations

This commit is contained in:
calc84maniac 2012-01-04 14:05:55 -05:00
parent 57d1c87a2d
commit ecc63651c7
1 changed files with 35 additions and 35 deletions

View File

@ -1722,32 +1722,28 @@ void Jit64::srawx(UGeckoInstruction inst)
int s = inst.RS; int s = inst.RS;
gpr.Lock(a, s, b); gpr.Lock(a, s, b);
gpr.FlushLockX(ECX); gpr.FlushLockX(ECX);
gpr.BindToRegister(a, a == s || a == b, true); gpr.BindToRegister(a, true, true);
JitClearCA();
MOV(32, R(ECX), gpr.R(b)); MOV(32, R(ECX), gpr.R(b));
TEST(32, R(ECX), Imm32(32));
FixupBranch topBitSet = J_CC(CC_NZ);
if (a != s) if (a != s)
MOV(32, gpr.R(a), gpr.R(s)); MOV(32, gpr.R(a), gpr.R(s));
MOV(32, R(EAX), Imm32(1)); TEST(32, R(ECX), Imm32(32));
SHL(32, R(EAX), R(ECX)); FixupBranch topBitSet = J_CC(CC_NZ);
ADD(32, R(EAX), Imm32(0x7FFFFFFF)); LEA(32, EAX, MComplex(gpr.RX(a), gpr.RX(a), 1, 0));
AND(32, R(EAX), gpr.R(a));
ADD(32, R(EAX), Imm32(-1));
CMP(32, R(EAX), Imm32(-1));
SETcc(CC_L, R(EAX));
SAR(32, gpr.R(a), R(ECX)); SAR(32, gpr.R(a), R(ECX));
AND(32, M(&PowerPC::ppcState.spr[SPR_XER]), Imm32(~(1 << 29))); NOT(32, R(ECX));
SHL(32, R(EAX), Imm8(29)); SHL(32, R(EAX), R(ECX));
OR(32, M(&PowerPC::ppcState.spr[SPR_XER]), R(EAX)); TEST(32, R(EAX), gpr.R(a));
FixupBranch nocarry1 = J_CC(CC_Z);
JitSetCA();
FixupBranch end = J(); FixupBranch end = J();
SetJumpTarget(topBitSet); SetJumpTarget(topBitSet);
MOV(32, R(EAX), gpr.R(s)); SAR(32, gpr.R(a), Imm8(31));
SAR(32, R(EAX), Imm8(31)); FixupBranch nocarry2 = J_CC(CC_Z);
MOV(32, gpr.R(a), R(EAX)); JitSetCA();
AND(32, M(&PowerPC::ppcState.spr[SPR_XER]), Imm32(~(1 << 29)));
AND(32, R(EAX), Imm32(1<<29));
OR(32, M(&PowerPC::ppcState.spr[SPR_XER]), R(EAX));
SetJumpTarget(end); SetJumpTarget(end);
SetJumpTarget(nocarry1);
SetJumpTarget(nocarry2);
gpr.UnlockAll(); gpr.UnlockAll();
gpr.UnlockAllX(); gpr.UnlockAllX();
@ -1767,19 +1763,22 @@ void Jit64::srawix(UGeckoInstruction inst)
{ {
gpr.Lock(a, s); gpr.Lock(a, s);
gpr.BindToRegister(a, a == s, true); gpr.BindToRegister(a, a == s, true);
MOV(32, R(EAX), gpr.R(s));
MOV(32, gpr.R(a), R(EAX));
SAR(32, gpr.R(a), Imm8(amount));
CMP(32, R(EAX), Imm8(0));
FixupBranch nocarry1 = J_CC(CC_GE);
TEST(32, R(EAX), Imm32((u32)0xFFFFFFFF >> (32 - amount))); // were any 1s shifted out?
FixupBranch nocarry2 = J_CC(CC_Z);
JitSetCA();
FixupBranch carry = J(false);
SetJumpTarget(nocarry1);
SetJumpTarget(nocarry2);
JitClearCA(); JitClearCA();
SetJumpTarget(carry); MOV(32, R(EAX), gpr.R(s));
if (a != s)
{
MOV(32, gpr.R(a), R(EAX));
}
SAR(32, gpr.R(a), Imm8(amount));
if (inst.Rc)
{
GenerateRC();
}
SHL(32, R(EAX), Imm8(32-amount));
TEST(32, R(EAX), gpr.R(a));
FixupBranch nocarry = J_CC(CC_Z);
JitSetCA();
SetJumpTarget(nocarry);
gpr.UnlockAll(); gpr.UnlockAll();
} }
else else
@ -1789,13 +1788,14 @@ void Jit64::srawix(UGeckoInstruction inst)
JitClearCA(); JitClearCA();
gpr.BindToRegister(a, a == s, true); gpr.BindToRegister(a, a == s, true);
if (a != s) if (a != s)
{
MOV(32, gpr.R(a), gpr.R(s)); MOV(32, gpr.R(a), gpr.R(s));
}
if (inst.Rc) {
ComputeRC(gpr.R(a));
}
gpr.UnlockAll(); gpr.UnlockAll();
} }
if (inst.Rc) {
ComputeRC(gpr.R(a));
}
} }
// count leading zeroes // count leading zeroes