Skip to content

Commit 43a9236

Browse files
JIT: Remove bbFallsThrough check in optFindLoopCompactionInsertionPoint (#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."
1 parent 8fbfb32 commit 43a9236

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/coreclr/jit/optimizer.cpp

+33-1
Original file line numberDiff line numberDiff line change
@@ -2889,8 +2889,40 @@ BasicBlock* Compiler::optFindLoopCompactionInsertionPoint(FlowGraphNaturalLoop*
28892889
// out of the loop, and if possible find a spot that won't break up fall-through.
28902890
BasicBlock* bottom = loop->GetLexicallyBottomMostBlock();
28912891
BasicBlock* insertionPoint = bottom;
2892-
while (insertionPoint->bbFallsThrough() && !insertionPoint->IsLast())
2892+
while (!insertionPoint->IsLast())
28932893
{
2894+
switch (insertionPoint->GetKind())
2895+
{
2896+
case BBJ_ALWAYS:
2897+
if (!insertionPoint->JumpsToNext())
2898+
{
2899+
// Found a branch that isn't to the next block, so we won't split up any fall-through.
2900+
return insertionPoint;
2901+
}
2902+
break;
2903+
2904+
case BBJ_COND:
2905+
if (!insertionPoint->FalseTargetIs(insertionPoint->Next()))
2906+
{
2907+
// Found a conditional branch that doesn't have a false branch to the next block,
2908+
// so we won't split up any fall-through.
2909+
return insertionPoint;
2910+
}
2911+
break;
2912+
2913+
case BBJ_CALLFINALLY:
2914+
if (!insertionPoint->isBBCallFinallyPair())
2915+
{
2916+
// Found a retless BBJ_CALLFINALLY block, so we won't split up any fall-through.
2917+
return insertionPoint;
2918+
}
2919+
break;
2920+
2921+
default:
2922+
// No fall-through to split up.
2923+
return insertionPoint;
2924+
}
2925+
28942926
// Keep looking for a better insertion point if we can.
28952927
BasicBlock* newInsertionPoint = optTryAdvanceLoopCompactionInsertionPoint(loop, insertionPoint, top, bottom);
28962928
if (newInsertionPoint == nullptr)

0 commit comments

Comments
 (0)