Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Reverse the loop order
  • Loading branch information
kunalspathak committed Jun 7, 2022
commit 3afcfb55e23d1919e15744dea3f06ec63615f6c1
11 changes: 10 additions & 1 deletion src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6301,11 +6301,20 @@ void Compiler::optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt)

BitVecTraits m_visitedTraits(fgBBNumMax * 2, this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the * 2 here? Are we expecting this many new blocks to appear?

I would (perhaps) expect one per loop, if we are creating preheaders for each.

Copy link
Contributor Author

@kunalspathak kunalspathak Jun 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was little conservative. I can probably do something like fgBBNumMax + loopCount.

BitVec m_visited(BitVecOps::MakeEmpty(&m_visitedTraits));
hoistCtxt->PushVnSetForSiblingLoop(this);

// Since loops in optLoopTable are arranged in reverse execution order, arrange
// them back in execution order before processing.
ArrayStack<unsigned> childLoops(getAllocatorLoopHoist());
for (unsigned child = optLoopTable[lnum].lpChild; child != BasicBlock::NOT_IN_LOOP;
child = optLoopTable[child].lpSibling)
{
childLoops.Push(child);
}

hoistCtxt->PushVnSetForSiblingLoop(this);
while (!childLoops.Empty())
{
unsigned child = childLoops.Pop();
optHoistLoopNest(child, hoistCtxt);
VNSet* hoistedInCurLoop = hoistCtxt->ExtractHoistedInCurLoop();

Expand Down