Skip to content

Commit

Permalink
JIT: Propagate physical promotion liveness in post-order (#104554)
Browse files Browse the repository at this point in the history
We now have a DFS tree available in physical promotion. This mean that
like normal liveness we can maximize the information propagated on every
iteration by running physical promotion's dataflow in post-order.
  • Loading branch information
jakobbotsch authored Jul 8, 2024
1 parent 8b9ea5e commit a0f0c6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/coreclr/jit/promotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ class PromotionLiveness
unsigned* m_structLclToTrackedIndex = nullptr;
unsigned m_numVars = 0;
BasicBlockLiveness* m_bbInfo = nullptr;
bool m_hasPossibleBackEdge = false;
BitVec m_liveIn;
BitVec m_ehLiveVars;
JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, BitVec> m_aggDeaths;
Expand Down
17 changes: 6 additions & 11 deletions src/coreclr/jit/promotionliveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,22 +294,19 @@ void PromotionLiveness::MarkIndex(unsigned index, bool isUse, bool isDef, BitVec
//
void PromotionLiveness::InterBlockLiveness()
{
FlowGraphDfsTree* dfsTree = m_compiler->m_dfsTree;
assert(dfsTree != nullptr);

bool changed;
do
{
changed = false;

for (BasicBlock* block = m_compiler->fgLastBB; block != nullptr; block = block->Prev())
{
m_hasPossibleBackEdge |= !block->IsLast() && (block->Next()->bbNum <= block->bbNum);
changed |= PerBlockLiveness(block);
}

if (!m_hasPossibleBackEdge)
for (unsigned i = 0; i < dfsTree->GetPostOrderCount(); i++)
{
break;
changed |= PerBlockLiveness(dfsTree->GetPostOrder(i));
}
} while (changed);
} while (changed && dfsTree->HasCycle());

#ifdef DEBUG
if (m_compiler->verbose)
Expand Down Expand Up @@ -345,7 +342,6 @@ bool PromotionLiveness::PerBlockLiveness(BasicBlock* block)
BitVecOps::ClearD(m_bvTraits, bbInfo.LiveOut);
block->VisitRegularSuccs(m_compiler, [=, &bbInfo](BasicBlock* succ) {
BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_bbInfo[succ->bbNum].LiveIn);
m_hasPossibleBackEdge |= succ->bbNum <= block->bbNum;
return BasicBlockVisit::Continue;
});

Expand All @@ -357,7 +353,6 @@ bool PromotionLiveness::PerBlockLiveness(BasicBlock* block)
AddHandlerLiveVars(block, m_ehLiveVars);
BitVecOps::UnionD(m_bvTraits, m_liveIn, m_ehLiveVars);
BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_ehLiveVars);
m_hasPossibleBackEdge = true;
}

bool liveInChanged = !BitVecOps::Equal(m_bvTraits, bbInfo.LiveIn, m_liveIn);
Expand Down

0 comments on commit a0f0c6c

Please sign in to comment.