JitArm64: cmp - Optimize a == -1 case

By explicitly handling this, we can avoid materializing -1 in a
register and generate more efficient code by taking advantage of -x ==
~x + 1.

Before:
0x12800015   mov    w21, #-0x1
0x93407eb9   sxtw   x25, w21
0x93407ef8   sxtw   x24, w23
0xcb180338   sub    x24, x25, x24

After:
0x2a3703f8   mvn    w24, w23
0x93407f18   sxtw   x24, w24
This commit is contained in:
Bram Speeckaert 2022-11-01 12:00:16 +01:00
parent 592ba31e22
commit 82f22cdfa1
1 changed files with 5 additions and 0 deletions

View File

@ -584,6 +584,11 @@ void JitArm64::cmp(UGeckoInstruction inst)
NEG(EncodeRegTo32(CR), gpr.R(b)); NEG(EncodeRegTo32(CR), gpr.R(b));
SXTW(CR, EncodeRegTo32(CR)); SXTW(CR, EncodeRegTo32(CR));
} }
else if (gpr.IsImm(a) && gpr.GetImm(a) == 0xFFFFFFFF)
{
MVN(EncodeRegTo32(CR), gpr.R(b));
SXTW(CR, EncodeRegTo32(CR));
}
else if (gpr.IsImm(b) && !gpr.GetImm(b)) else if (gpr.IsImm(b) && !gpr.GetImm(b))
{ {
SXTW(CR, gpr.R(a)); SXTW(CR, gpr.R(a));