Skip to content

Commit

Permalink
JIT: Remove bbFallsThrough check in optFindLoopCompactionInsertionPoi…
Browse files Browse the repository at this point in the history
…nt (#99827)

Calling bbFallsThrough isn't all that helpful here, as it doesn't consider BBJ_ALWAYS blocks to the next block, BBJ_COND blocks that don't fall through for the false path, etc. I'm planning on getting rid of bbFallsThrough everywhere except in fgReorderBlocks (that removal will hopefully come when we replace our block layout algorithm altogether), but to still be able to short-circuit optFindLoopCompactionInsertionPoint, I added some manual checks for blocks that can "fall through."
  • Loading branch information
amanasifkhalid committed Mar 19, 2024
1 parent 8fbfb32 commit 43a9236
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/coreclr/jit/optimizer.cpp
Expand Up @@ -2889,8 +2889,40 @@ BasicBlock* Compiler::optFindLoopCompactionInsertionPoint(FlowGraphNaturalLoop*
// out of the loop, and if possible find a spot that won't break up fall-through.
BasicBlock* bottom = loop->GetLexicallyBottomMostBlock();
BasicBlock* insertionPoint = bottom;
while (insertionPoint->bbFallsThrough() && !insertionPoint->IsLast())
while (!insertionPoint->IsLast())
{
switch (insertionPoint->GetKind())
{
case BBJ_ALWAYS:
if (!insertionPoint->JumpsToNext())
{
// Found a branch that isn't to the next block, so we won't split up any fall-through.
return insertionPoint;
}
break;

case BBJ_COND:
if (!insertionPoint->FalseTargetIs(insertionPoint->Next()))
{
// Found a conditional branch that doesn't have a false branch to the next block,
// so we won't split up any fall-through.
return insertionPoint;
}
break;

case BBJ_CALLFINALLY:
if (!insertionPoint->isBBCallFinallyPair())
{
// Found a retless BBJ_CALLFINALLY block, so we won't split up any fall-through.
return insertionPoint;
}
break;

default:
// No fall-through to split up.
return insertionPoint;
}

// Keep looking for a better insertion point if we can.
BasicBlock* newInsertionPoint = optTryAdvanceLoopCompactionInsertionPoint(loop, insertionPoint, top, bottom);
if (newInsertionPoint == nullptr)
Expand Down

0 comments on commit 43a9236

Please sign in to comment.