JitArm64: mulli - Only allocate reg when necessary

If the destination register doesn't equal the input register, using it
to temporarily hold the immediate value is fair game as it'll be
overwritten with the result of the multiplication anyway. This can
slightly reduce register pressure.

Before:

0x52800659   mov    w25, #0x32
0x1b197f5b   mul    w27, w26, w25

After:
0x5280065b   mov    w27, #0x32
0x1b1b7f5b   mul    w27, w26, w27
This commit is contained in:
Bram Speeckaert 2022-11-01 21:28:41 +01:00
parent 20dd5cadab
commit 1c87f040a3
1 changed files with 8 additions and 3 deletions

View File

@ -944,11 +944,16 @@ void JitArm64::mulli(UGeckoInstruction inst)
}
else
{
gpr.BindToRegister(d, d == a);
ARM64Reg WA = gpr.GetReg();
const bool allocate_reg = d == a;
gpr.BindToRegister(d, allocate_reg);
// Reuse d to hold the immediate if possible, allocate a register otherwise.
ARM64Reg WA = allocate_reg ? gpr.GetReg() : gpr.R(d);
MOVI2R(WA, (u32)(s32)inst.SIMM_16);
MUL(gpr.R(d), gpr.R(a), WA);
gpr.Unlock(WA);
if (allocate_reg)
gpr.Unlock(WA);
}
}