Skip to content
Permalink
Browse files
Merge pull request #7631 from MerryMage/crXXX-AeqB
Jit_SystemRegisters: Special-case crXXX for CRBA == CRBB
  • Loading branch information
degasus committed Dec 23, 2018
2 parents fc99809 + 174d2b0 commit 54f37c3
Showing 1 changed file with 31 additions and 14 deletions.
@@ -552,24 +552,41 @@ void Jit64::crXXX(UGeckoInstruction inst)
JITDISABLE(bJITSystemRegistersOff);
DEBUG_ASSERT_MSG(DYNA_REC, inst.OPCD == 19, "Invalid crXXX");

// Special case: crclr
if (inst.CRBA == inst.CRBB && inst.CRBA == inst.CRBD && inst.SUBOP10 == 193)
{
ClearCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3));
return;
}
// TODO(merry): Futher optimizations can be performed here. For example,
// instead of extracting each CR field bit then setting it, the operation
// could be performed on the internal format directly instead and the
// relevant bit result can be masked out.

// Special case: crset
if (inst.CRBA == inst.CRBB && inst.CRBA == inst.CRBD && inst.SUBOP10 == 289)
if (inst.CRBA == inst.CRBB)
{
SetCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3));
return;
switch (inst.SUBOP10)
{
// crclr
case 129: // crandc: A && ~B => 0
case 193: // crxor: A ^ B => 0
ClearCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3));
return;

// crset
case 289: // creqv: ~(A ^ B) => 1
case 417: // crorc: A || ~B => 1
SetCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3));
return;

case 257: // crand: A && B => A
case 449: // cror: A || B => A
GetCRFieldBit(inst.CRBA >> 2, 3 - (inst.CRBA & 3), RSCRATCH, false);
SetCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3), RSCRATCH);
return;

case 33: // crnor: ~(A || B) => ~A
case 225: // crnand: ~(A && B) => ~A
GetCRFieldBit(inst.CRBA >> 2, 3 - (inst.CRBA & 3), RSCRATCH, true);
SetCRFieldBit(inst.CRBD >> 2, 3 - (inst.CRBD & 3), RSCRATCH);
return;
}
}

// TODO(delroth): Potential optimizations could be applied here. For
// instance, if the two CR bits being loaded are the same, two loads are
// not required.

// creqv or crnand or crnor
bool negateA = inst.SUBOP10 == 289 || inst.SUBOP10 == 225 || inst.SUBOP10 == 33;
// crandc or crorc or crnand or crnor

0 comments on commit 54f37c3

Please sign in to comment.