Skip to content

Commit 272948a

Browse files
JIT: Remove early fgOptimizeBranch pass (#115734)
Part of #107749. fgOptimizeBranch looks for cases where a block jumps to a conditional block, which jumps back to the lexical successor of the first block. When it is profitable, fgOptimizeBranch clones the condition into the first block to avoid the jump-check-jump pattern. While probably more pattern-matchy in its analysis than ideal, this can help block layout align loops properly. However, I see little reason to run this transformation early, especially before loop recognition; from the diffs, fgOptimizeBranch seems to create unnatural loop shapes with some frequency, pessimizing downstream loop opts. Removing the early pass means we can also make the late pass more aggressive without splitting off the implementation.
1 parent 28e603e commit 272948a

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/coreclr/jit/optimizer.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,20 +2391,6 @@ PhaseStatus Compiler::optOptimizeFlow()
23912391
modified |= fgExpandRarelyRunBlocks();
23922392
}
23932393

2394-
// Run branch optimizations for non-handler blocks.
2395-
assert(!fgFuncletsCreated);
2396-
for (BasicBlock* block = fgFirstBB; block != nullptr; block = block->Next())
2397-
{
2398-
if (block->hasHndIndex())
2399-
{
2400-
assert(bbIsHandlerBeg(block));
2401-
block = ehGetDsc(block->getHndIndex())->ebdHndLast;
2402-
continue;
2403-
}
2404-
2405-
modified |= fgOptimizeBranch(block);
2406-
}
2407-
24082394
return modified ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
24092395
}
24102396

0 commit comments

Comments
 (0)