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

Commit f503a56

Browse files
committed
Hoist calls to NumSucc() out of loops
Should be a minor throughput improvement.
1 parent b23add0 commit f503a56

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
@@ -15426,7 +15426,8 @@ inline void Compiler::impReimportMarkBlock(BasicBlock* block)
1542615426

1542715427
void Compiler::impReimportMarkSuccessors(BasicBlock* block)
1542815428
{
15429-
for (unsigned i = 0; i < block->NumSucc(); i++)
15429+
const unsigned numSuccs = block->NumSucc();
15430+
for (unsigned i = 0; i < numSuccs; i++)
1543015431
{
1543115432
impReimportMarkBlock(block->GetSucc(i));
1543215433
}
@@ -15601,7 +15602,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1560115602
JITDUMP("Marking BBF_INTERNAL block BB%02u as BBF_IMPORTED\n", block->bbNum);
1560215603
block->bbFlags |= BBF_IMPORTED;
1560315604

15604-
for (unsigned i = 0; i < block->NumSucc(); i++)
15605+
const unsigned numSuccs = block->NumSucc();
15606+
for (unsigned i = 0; i < numSuccs; i++)
1560515607
{
1560615608
impImportBlockPending(block->GetSucc(i));
1560715609
}
@@ -16028,7 +16030,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1602816030
impReimportSpillClique(block);
1602916031

1603016032
// For blocks that haven't been imported yet, we still need to mark them as pending import.
16031-
for (unsigned i = 0; i < block->NumSucc(); i++)
16033+
const unsigned numSuccs = block->NumSucc();
16034+
for (unsigned i = 0; i < numSuccs; i++)
1603216035
{
1603316036
BasicBlock* succ = block->GetSucc(i);
1603416037
if ((succ->bbFlags & BBF_IMPORTED) == 0)
@@ -16042,7 +16045,8 @@ void Compiler::impImportBlock(BasicBlock* block)
1604216045
// otherwise just import the successors of block
1604316046

1604416047
/* Does this block jump to any other blocks? */
16045-
for (unsigned i = 0; i < block->NumSucc(); i++)
16048+
const unsigned numSuccs = block->NumSucc();
16049+
for (unsigned i = 0; i < numSuccs; i++)
1604616050
{
1604716051
impImportBlockPending(block->GetSucc(i));
1604816052
}
@@ -16299,7 +16303,8 @@ void Compiler::impWalkSpillCliqueFromPred(BasicBlock* block, SpillCliqueWalker*
1629916303
BasicBlock* blk = node->m_blk;
1630016304
FreeBlockListNode(node);
1630116305

16302-
for (unsigned succNum = 0; succNum < blk->NumSucc(); succNum++)
16306+
const unsigned numSuccs = blk->NumSucc();
16307+
for (unsigned succNum = 0; succNum < numSuccs; succNum++)
1630316308
{
1630416309
BasicBlock* succ = blk->GetSucc(succNum);
1630516310
// 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)