JitArm64_Integer: cmpl - Subtract shifted 12-bit constant

You can encode a shifted 12-bit immediate in a SUB instruction on ARM64.
We exploit this to avoid materializing the immediate.

This approach saves an instruction if it does not need to be
materialized in a register afterwards. Otherwise, we just materialize
it later and the total number of instructions stays the same.

Before:
0x52a00218   mov    w24, #0x100000            ; =1048576
0xcb180379   sub    x25, x27, x24

After:
0xd1440379   sub    x25, x27, #0x100, lsl #12 ; =0x100000
This commit is contained in:
Sintendo 2025-02-01 22:02:43 +01:00
parent b7c3f91643
commit 7ce7da629e
1 changed files with 4 additions and 0 deletions

View File

@ -736,6 +736,10 @@ void JitArm64::cmpl(UGeckoInstruction inst)
else
SUB(CR, EncodeRegTo64(gpr.R(a)), imm);
}
else if (gpr.IsImm(b) && (gpr.GetImm(b) & 0xFFF000) == gpr.GetImm(b))
{
SUB(CR, EncodeRegTo64(gpr.R(a)), gpr.GetImm(b) >> 12, true);
}
else
{
SUB(CR, EncodeRegTo64(gpr.R(a)), EncodeRegTo64(gpr.R(b)));