PPCAnalyst: Less strict interrupt checks in CanSwapAdjacentOps

When these checks were originally added, we didn't have the nice
canCauseException attribute. Now we do, so let's use it.
This commit is contained in:
JosJuice 2021-06-29 15:54:50 +02:00
parent 85d2ea0dd2
commit ab8b2f9fe0

View File

@ -205,6 +205,14 @@ bool PPCAnalyzer::CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b) const
{ {
return false; return false;
} }
// Any instruction which can raise an interrupt is *not* a possible swap candidate:
// see [1] for an example of a crash caused by this error.
//
// [1] https://bugs.dolphin-emu.org/issues/5864#note-7
if (a.canCauseException || b.canCauseException)
return false;
if (a_flags & FL_ENDBLOCK)
return false;
if (b_flags & (FL_SET_CRx | FL_ENDBLOCK | FL_TIMER | FL_EVIL | FL_SET_OE)) if (b_flags & (FL_SET_CRx | FL_ENDBLOCK | FL_TIMER | FL_EVIL | FL_SET_OE))
return false; return false;
if ((b_flags & (FL_RC_BIT | FL_RC_BIT_F)) && (b.inst.Rc)) if ((b_flags & (FL_RC_BIT | FL_RC_BIT_F)) && (b.inst.Rc))
@ -223,18 +231,10 @@ bool PPCAnalyzer::CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b) const
return false; return false;
} }
// For now, only integer ops acceptable. Any instruction which can raise an // For now, only integer ops are acceptable.
// interrupt is *not* a possible swap candidate: see [1] for an example of
// a crash caused by this error.
//
// [1] https://bugs.dolphin-emu.org/issues/5864#note-7
if (b_info->type != OpType::Integer) if (b_info->type != OpType::Integer)
return false; return false;
// And it's possible a might raise an interrupt too (fcmpo/fcmpu)
if (a_info->type != OpType::Integer)
return false;
// Check that we have no register collisions. // Check that we have no register collisions.
// That is, check that none of b's outputs matches any of a's inputs, // That is, check that none of b's outputs matches any of a's inputs,
// and that none of a's outputs matches any of b's inputs. // and that none of a's outputs matches any of b's inputs.