PPCAnalyst: Fix gprBlockInputs calculation

This analysis needs to scan backwards, not forwards.
This commit is contained in:
JosJuice 2023-07-27 23:09:46 +02:00
parent 17fa9dfc4e
commit 8c2d73e8c2
1 changed files with 4 additions and 5 deletions

View File

@ -947,7 +947,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
BitSet8 wantsCR = BitSet8(0xFF);
bool wantsFPRF = true;
bool wantsCA = true;
BitSet32 fprInUse, gprInUse, gprDiscardable, fprDiscardable, fprInXmm;
BitSet32 gprDefined, gprBlockInputs, gprInUse, fprInUse, gprDiscardable, fprDiscardable, fprInXmm;
for (int i = block->m_num_instructions - 1; i >= 0; i--)
{
CodeOp& op = code[i];
@ -969,6 +969,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
op.gprDiscardable = gprDiscardable;
op.fprDiscardable = fprDiscardable;
op.fprInXmm = fprInXmm;
gprBlockInputs |= op.regsIn & ~gprDefined;
gprDefined |= op.regsOut;
gprInUse |= op.regsIn | op.regsOut;
fprInUse |= op.fregsIn | op.GetFregsOut();
if (op.canEndBlock || op.canCauseException)
@ -988,15 +990,12 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
}
// Forward scan, for flags that need the other direction for calculation.
BitSet32 fprIsSingle, fprIsDuplicated, fprIsStoreSafe, gprDefined, gprBlockInputs;
BitSet32 fprIsSingle, fprIsDuplicated, fprIsStoreSafe;
BitSet8 gqrUsed, gqrModified;
for (u32 i = 0; i < block->m_num_instructions; i++)
{
CodeOp& op = code[i];
gprBlockInputs |= op.regsIn & ~gprDefined;
gprDefined |= op.regsOut;
op.fprIsSingle = fprIsSingle;
op.fprIsDuplicated = fprIsDuplicated;
op.fprIsStoreSafeBeforeInst = fprIsStoreSafe;