Skip to content

Commit 1c87f04

Browse files
committed
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
1 parent 20dd5ca commit 1c87f04

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,16 @@ void JitArm64::mulli(UGeckoInstruction inst)
944944
}
945945
else
946946
{
947-
gpr.BindToRegister(d, d == a);
948-
ARM64Reg WA = gpr.GetReg();
947+
const bool allocate_reg = d == a;
948+
gpr.BindToRegister(d, allocate_reg);
949+
950+
// Reuse d to hold the immediate if possible, allocate a register otherwise.
951+
ARM64Reg WA = allocate_reg ? gpr.GetReg() : gpr.R(d);
952+
949953
MOVI2R(WA, (u32)(s32)inst.SIMM_16);
950954
MUL(gpr.R(d), gpr.R(a), WA);
951-
gpr.Unlock(WA);
955+
if (allocate_reg)
956+
gpr.Unlock(WA);
952957
}
953958
}
954959

0 commit comments

Comments
 (0)