Jit64: divwx - Micro-optimize division by 2

Prefer using eax to isolate the sign bit. This saves a byte when the
destination ends up as r8-15, because those require a REX prefix.

Before:
41 8B C5             mov         eax,r13d
41 C1 ED 1F          shr         r13d,1Fh
44 03 E8             add         r13d,eax
41 D1 FD             sar         r13d,1

After:
41 8B C5             mov         eax,r13d
C1 E8 1F             shr         eax,1Fh
44 03 E8             add         r13d,eax
41 D1 FD             sar         r13d,1
This commit is contained in:
Sintendo 2021-11-02 23:52:21 +01:00
parent f18f6cd0a2
commit dfb32040bf
1 changed files with 4 additions and 1 deletions

View File

@ -1494,6 +1494,8 @@ void Jit64::divwx(UGeckoInstruction inst)
else if (divisor == 2 || divisor == -2)
{
X64Reg tmp = RSCRATCH;
X64Reg sign = tmp;
if (!Ra.IsSimpleReg())
{
// Load dividend from memory
@ -1510,9 +1512,10 @@ void Jit64::divwx(UGeckoInstruction inst)
// Copy dividend directly into destination
MOV(32, Rd, Ra);
tmp = Ra.GetSimpleReg();
sign = Rd;
}
SHR(32, Rd, Imm8(31));
SHR(32, R(sign), Imm8(31));
ADD(32, Rd, R(tmp));
SAR(32, Rd, Imm8(1));