Skip to content

Commit b0bcb45

Browse files
amanasifkhalidmikelle-rogers
authored andcommitted
JIT: Remove fgRenumberBlocks calls in loop opt phases (dotnet#110227)
Follow-up to dotnet#110026. This required a small refactor of FlowGraphNaturalLoop::VisitLoopBlocksLexical to remove its bbNum checks.
1 parent 87b6a93 commit b0bcb45

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

src/coreclr/jit/compiler.hpp

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,37 +5145,18 @@ BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocks(TFunc func)
51455145
template <typename TFunc>
51465146
BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksLexical(TFunc func)
51475147
{
5148-
BasicBlock* top = m_header;
5149-
unsigned numLoopBlocks = 0;
5150-
VisitLoopBlocks([&](BasicBlock* block) {
5151-
if (block->bbNum < top->bbNum)
5152-
{
5153-
top = block;
5154-
}
5155-
5156-
numLoopBlocks++;
5157-
return BasicBlockVisit::Continue;
5158-
});
5148+
BasicBlock* const top = GetLexicallyTopMostBlock();
5149+
BasicBlock* const bottom = GetLexicallyBottomMostBlock();
51595150

5160-
INDEBUG(BasicBlock* prev = nullptr);
5161-
BasicBlock* cur = top;
5162-
while (numLoopBlocks > 0)
5151+
for (BasicBlock* const block : m_dfsTree->GetCompiler()->Blocks(top, bottom))
51635152
{
5164-
// If we run out of blocks the blocks aren't sequential.
5165-
assert(cur != nullptr);
5166-
5167-
if (ContainsBlock(cur))
5153+
if (ContainsBlock(block))
51685154
{
5169-
assert((prev == nullptr) || (prev->bbNum < cur->bbNum));
5170-
5171-
if (func(cur) == BasicBlockVisit::Abort)
5155+
if (func(block) == BasicBlockVisit::Abort)
5156+
{
51725157
return BasicBlockVisit::Abort;
5173-
5174-
INDEBUG(prev = cur);
5175-
numLoopBlocks--;
5158+
}
51765159
}
5177-
5178-
cur = cur->Next();
51795160
}
51805161

51815162
return BasicBlockVisit::Continue;

src/coreclr/jit/loopcloning.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,8 +3064,6 @@ PhaseStatus Compiler::optCloneLoops()
30643064
m_dfsTree = fgComputeDfs();
30653065
m_loops = FlowGraphNaturalLoops::Find(m_dfsTree);
30663066
}
3067-
3068-
fgRenumberBlocks();
30693067
}
30703068

30713069
#ifdef DEBUG

src/coreclr/jit/optimizer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ PhaseStatus Compiler::optUnrollLoops()
13031303
}
13041304

13051305
JITDUMP("A nested loop was unrolled. Doing another pass (pass %d)\n", passes + 1);
1306-
fgRenumberBlocks();
13071306
fgInvalidateDfsTree();
13081307
m_dfsTree = fgComputeDfs();
13091308
m_loops = FlowGraphNaturalLoops::Find(m_dfsTree);

0 commit comments

Comments
 (0)