Jit64: srawx - Handle constant input registers

If both input registers hold known values at compile time, we can just
calculate the result on the spot.

Code has mostly been copied from JitArm64 where it had already been implemented.

Before:
BF FF FF FF FF       mov         edi,0FFFFFFFFh
8B C7                mov         eax,edi
C1 FF 10             sar         edi,10h
C1 E0 10             shl         eax,10h
85 F8                test        eax,edi
0F 95 45 58          setne       byte ptr [rbp+58h]

After:
C6 45 58 01          mov         byte ptr [rbp+58h],1
This commit is contained in:
Sintendo 2020-11-18 23:20:30 +01:00
parent b968120f8a
commit 8ac40162da
1 changed files with 16 additions and 1 deletions

View File

@ -1907,7 +1907,22 @@ void Jit64::srawx(UGeckoInstruction inst)
int b = inst.RB;
int s = inst.RS;
if (gpr.IsImm(b))
if (gpr.IsImm(b, s))
{
s32 i = gpr.SImm32(s), amount = gpr.SImm32(b);
if (amount & 0x20)
{
gpr.SetImmediate32(a, i & 0x80000000 ? 0xFFFFFFFF : 0);
FinalizeCarry(i & 0x80000000 ? true : false);
}
else
{
amount &= 0x1F;
gpr.SetImmediate32(a, i >> amount);
FinalizeCarry(amount != 0 && i < 0 && (u32(i) << (32 - amount)));
}
}
else if (gpr.IsImm(b))
{
u32 amount = gpr.Imm32(b);
RCX64Reg Ra = gpr.Bind(a, RCMode::Write);