mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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,14 +1841,36 @@ 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));
|
||||
SAR(32, gpr.R(a), Imm8(amount));
|
||||
SHL(32, R(RSCRATCH), Imm8(32 - amount));
|
||||
TEST(32, R(RSCRATCH), gpr.R(a));
|
||||
JitSetCAIf(CC_NZ);
|
||||
// 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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user