JIT64: optimize some special cases of srawix
Shift by 31 and 1, both of which are pretty common, can be done in a few less instructions. Tested with a hwtest.
This commit is contained in:
parent
a95d8cbcb4
commit
b56117de05
|
@ -1841,15 +1841,37 @@ void Jit64::srawix(UGeckoInstruction inst)
|
|||
{
|
||||
gpr.Lock(a, s);
|
||||
gpr.BindToRegister(a, a == s, true);
|
||||
JitClearCAOV(false);
|
||||
MOV(32, R(RSCRATCH), gpr.R(s));
|
||||
if (a != s)
|
||||
MOV(32, gpr.R(a), R(RSCRATCH));
|
||||
// some optimized common cases that can be done in slightly fewer ops
|
||||
if (amount == 31)
|
||||
{
|
||||
JitSetCA();
|
||||
SAR(32, gpr.R(a), Imm8(31));
|
||||
NEG(32, R(RSCRATCH)); // RSCRATCH = input == INT_MIN ? INT_MIN : -input;
|
||||
AND(32, R(RSCRATCH), Imm32(0x80000000)); // RSCRATCH = input < 0 && input != INT_MIN ? 0 : 0x80000000
|
||||
SHR(32, R(RSCRATCH), Imm8(31 - XER_CA_SHIFT));
|
||||
XOR(32, PPCSTATE(spr[SPR_XER]), R(RSCRATCH)); // XER.CA = (input < 0 && input != INT_MIN)
|
||||
}
|
||||
else if (amount == 1)
|
||||
{
|
||||
JitClearCAOV(false);
|
||||
SHR(32, R(RSCRATCH), Imm8(31)); // sign
|
||||
AND(32, R(RSCRATCH), gpr.R(a)); // (sign && carry)
|
||||
SAR(32, gpr.R(a), Imm8(1));
|
||||
SHL(32, R(RSCRATCH), Imm8(XER_CA_SHIFT));
|
||||
OR(32, PPCSTATE(spr[SPR_XER]), R(RSCRATCH)); // XER.CA = sign && carry, aka (input&0x80000001) == 0x80000001
|
||||
}
|
||||
else
|
||||
{
|
||||
JitClearCAOV(false);
|
||||
SAR(32, gpr.R(a), Imm8(amount));
|
||||
SHL(32, R(RSCRATCH), Imm8(32 - amount));
|
||||
TEST(32, R(RSCRATCH), gpr.R(a));
|
||||
JitSetCAIf(CC_NZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gpr.Lock(a, s);
|
||||
|
|
Loading…
Reference in New Issue