From 8ac40162da0b43ebfb668d6858639d9b49c491f5 Mon Sep 17 00:00:00 2001 From: Sintendo Date: Wed, 18 Nov 2020 23:20:30 +0100 Subject: [PATCH] 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 --- Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index fb782c8a66..e7591429e1 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -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);