JitArm64_Integer: subfex - Optimize InHostCarry case for -1

The result is either -1 or 0 depending on the state of the carry flag.
This can be done with a csetm instruction.

Before:
0x1280001a   mov    w26, #-0x1                ; =-1
0x1a1f035a   adc    w26, w26, wzr

After:
0x5a9f23fa   csetm  w26, lo
This commit is contained in:
Sintendo 2024-12-28 20:18:09 +01:00
parent 18dd3f69f1
commit fa13457abb

View File

@ -1244,8 +1244,18 @@ void JitArm64::subfex(UGeckoInstruction inst)
{ {
gpr.BindToRegister(d, false); gpr.BindToRegister(d, false);
ARM64Reg RD = gpr.R(d); ARM64Reg RD = gpr.R(d);
MOVI2R(RD, imm); if (is_all_ones)
ADC(RD, RD, ARM64Reg::WZR); {
// RD = -1 + carry = carry ? 0 : -1
// CSETM sets the destination to -1 if the condition is true, 0
// otherwise. Hence, the condition must be carry clear.
CSETM(RD, CC_CC);
}
else
{
MOVI2R(RD, imm);
ADC(RD, RD, ARM64Reg::WZR);
}
break; break;
} }
case CarryFlag::ConstantTrue: case CarryFlag::ConstantTrue: