From 10d65519f95b33221731aab1b96d98d69e5792f3 Mon Sep 17 00:00:00 2001 From: Sintendo Date: Sun, 13 Dec 2020 11:52:21 +0100 Subject: [PATCH] Jit64: slwx - Handle constant zero input Shifting zero by any amount always gives zero. Before: 41 BF 00 00 00 00 mov r15d,0 8B CF mov ecx,edi 49 D3 E7 shl r15,cl 45 8B FF mov r15d,r15d After: Nothing, register is set to constant zero. All games I've tried hit this optimization on launch. In Soul Calibur II it occurs very frequently during gameplay. --- Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 0e04f574a5..d32d75bb88 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -1892,6 +1892,12 @@ void Jit64::slwx(UGeckoInstruction inst) if (inst.Rc) ComputeRC(a); } + else if (gpr.IsImm(s) && gpr.Imm32(s) == 0) + { + gpr.SetImmediate32(a, 0); + if (inst.Rc) + ComputeRC(a); + } else { RCX64Reg ecx = gpr.Scratch(ECX); // no register choice