Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5555,20 +5555,21 @@ bool FlowGraphNaturalLoop::InitBlockEntersLoopOnTrue(BasicBlock* initBlock)
// the loop.
//
// Returns:
// Block with highest bbNum.
// First block in block order contained in the loop.
//
// Remarks:
// Mostly exists as a quirk while transitioning from the old loop
// representation to the new one.
//
BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock()
{
BasicBlock* top = m_header;
VisitLoopBlocks([&top](BasicBlock* loopBlock) {
if (loopBlock->bbNum < top->bbNum)
top = loopBlock;
return BasicBlockVisit::Continue;
});
BasicBlock* top = m_dfsTree->GetCompiler()->fgFirstBB;

while (!ContainsBlock(top))
{
top = top->Next();
assert(top != nullptr);
}

return top;
}
Expand All @@ -5578,20 +5579,21 @@ BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock()
// within the loop.
//
// Returns:
// Block with highest bbNum.
// Last block in block order contained in the loop.
//
// Remarks:
// Mostly exists as a quirk while transitioning from the old loop
// representation to the new one.
//
BasicBlock* FlowGraphNaturalLoop::GetLexicallyBottomMostBlock()
{
BasicBlock* bottom = m_header;
VisitLoopBlocks([&bottom](BasicBlock* loopBlock) {
if (loopBlock->bbNum > bottom->bbNum)
bottom = loopBlock;
return BasicBlockVisit::Continue;
});
BasicBlock* bottom = m_dfsTree->GetCompiler()->fgLastBB;

while (!ContainsBlock(bottom))
{
bottom = bottom->Prev();
assert(bottom != nullptr);
}

return bottom;
}
Expand Down