JitArm64: Optimize creqv setting eq/gt bit

For the eq and gt bits specifically, setting negate_result is one
instruction shorter than not setting it.
This commit is contained in:
JosJuice 2025-01-06 09:56:07 +01:00
parent c04ef2eed3
commit 82695ea6f4

View File

@ -635,8 +635,11 @@ void JitArm64::crXXX(UGeckoInstruction inst)
}
}
// crnor or crnand
const bool negate_result = inst.SUBOP10 == 33 || inst.SUBOP10 == 225;
const u32 crbd_bit = 3 - (inst.CRBD & 3);
// crnor, crnand and sometimes creqv
const bool negate_result =
inst.SUBOP10 == 33 || inst.SUBOP10 == 225 ||
(inst.SUBOP10 == 289 && (crbd_bit == PowerPC::CR_EQ_BIT || crbd_bit == PowerPC::CR_GT_BIT));
bool bits_1_to_31_are_set = false;
auto WA = gpr.GetScopedReg();
@ -666,8 +669,17 @@ void JitArm64::crXXX(UGeckoInstruction inst)
break;
case 289: // creqv: ~(A ^ B) = A ^ ~B
EON(WA, WA, WB);
bits_1_to_31_are_set = true;
// Both of these two implementations are equally correct, but which one is more efficient
// depends on which bit we're going to set in CRBD
if (negate_result)
{
ORR(XA, XA, XB);
}
else
{
EON(WA, WA, WB);
bits_1_to_31_are_set = true;
}
break;
case 33: // crnor: ~(A || B)