Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9051ff8

Browse files
Merge pull request #11035 from BruceForstall/NumSuccImprovement
Hoist calls to NumSucc() out of loops
2 parents 432e8bf + f503a56 commit 9051ff8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/jit/importer.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15507,7 +15507,8 @@ inline void Compiler::impReimportMarkBlock(BasicBlock* block)
1550715507

1550815508
void Compiler::impReimportMarkSuccessors(BasicBlock* block)
1550915509
{
15510-
for (unsigned i = 0; i < block->NumSucc(); i++)
15510+
const unsigned numSuccs = block->NumSucc();
15511+
for (unsigned i = 0; i < numSuccs; i++)
1551115512
{
1551215513
impReimportMarkBlock(block->GetSucc(i));
1551315514
}
@@ -15682,7 +15683,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1568215683
JITDUMP("Marking BBF_INTERNAL block BB%02u as BBF_IMPORTED\n", block->bbNum);
1568315684
block->bbFlags |= BBF_IMPORTED;
1568415685

15685-
for (unsigned i = 0; i < block->NumSucc(); i++)
15686+
const unsigned numSuccs = block->NumSucc();
15687+
for (unsigned i = 0; i < numSuccs; i++)
1568615688
{
1568715689
impImportBlockPending(block->GetSucc(i));
1568815690
}
@@ -16109,7 +16111,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1610916111
impReimportSpillClique(block);
1611016112

1611116113
// For blocks that haven't been imported yet, we still need to mark them as pending import.
16112-
for (unsigned i = 0; i < block->NumSucc(); i++)
16114+
const unsigned numSuccs = block->NumSucc();
16115+
for (unsigned i = 0; i < numSuccs; i++)
1611316116
{
1611416117
BasicBlock* succ = block->GetSucc(i);
1611516118
if ((succ->bbFlags & BBF_IMPORTED) == 0)
@@ -16123,7 +16126,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1612316126
// otherwise just import the successors of block
1612416127

1612516128
/* Does this block jump to any other blocks? */
16126-
for (unsigned i = 0; i < block->NumSucc(); i++)
16129+
const unsigned numSuccs = block->NumSucc();
16130+
for (unsigned i = 0; i < numSuccs; i++)
1612716131
{
1612816132
impImportBlockPending(block->GetSucc(i));
1612916133
}
@@ -16380,7 +16384,8 @@ void Compiler::impWalkSpillCliqueFromPred(BasicBlock* block, SpillCliqueWalker*
1638016384
BasicBlock* blk = node->m_blk;
1638116385
FreeBlockListNode(node);
1638216386

16383-
for (unsigned succNum = 0; succNum < blk->NumSucc(); succNum++)
16387+
const unsigned numSuccs = blk->NumSucc();
16388+
for (unsigned succNum = 0; succNum < numSuccs; succNum++)
1638416389
{
1638516390
BasicBlock* succ = blk->GetSucc(succNum);
1638616391
// If it's not already in the clique, add it, and also add it

src/jit/lsra.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,8 @@ void LinearScan::setBlockSequence()
13781378
assert(!"Switch with single successor");
13791379
}
13801380

1381-
for (unsigned succIndex = 0; succIndex < block->NumSucc(compiler); succIndex++)
1381+
const unsigned numSuccs = block->NumSucc(compiler);
1382+
for (unsigned succIndex = 0; succIndex < numSuccs; succIndex++)
13821383
{
13831384
BasicBlock* succ = block->GetSucc(succIndex, compiler);
13841385
if (checkForCriticalOutEdge && succ->GetUniquePred(compiler) == nullptr)

0 commit comments

Comments
 (0)