JitArm64: cmp - Optimize a == 0 case

By explicitly handling this, we can avoid materializing zero in a
register and generate more efficient code altogether.

Before:
0x52800016   mov    w22, #0x0
0xb94093b5   ldr    w21, [x29, #0x90]
0x93407ed7   sxtw   x23, w22
0x93407eb9   sxtw   x25, w21
0xcb1902f9   sub    x25, x23, x25

After:
0xb94093b7   ldr    w23, [x29, #0x90]
0x4b1703f9   neg    w25, w23
0x93407f39   sxtw   x25, w25
This commit is contained in:
Bram Speeckaert 2022-11-01 11:51:57 +01:00
parent f5e7e70cc5
commit 592ba31e22

View File

@ -579,6 +579,11 @@ void JitArm64::cmp(UGeckoInstruction inst)
s64 B = static_cast<s32>(gpr.GetImm(b));
MOVI2R(CR, A - B);
}
else if (gpr.IsImm(a) && !gpr.GetImm(a))
{
NEG(EncodeRegTo32(CR), gpr.R(b));
SXTW(CR, EncodeRegTo32(CR));
}
else if (gpr.IsImm(b) && !gpr.GetImm(b))
{
SXTW(CR, gpr.R(a));