Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4834,7 +4834,26 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh
{
bDest = block->GetTrueTarget();
bFalseDest = block->GetFalseTarget();
if (bDest == bFalseDest)

if (bFalseDest->KindIs(BBJ_ALWAYS) && bFalseDest->TargetIs(bDest) && bFalseDest->isEmpty())
{
// Optimize block -> bFalseDest -> bDest into a BBJ_ALWAYS
block->SetFalseTarget(bDest);
fgAddRefPred(bDest, block, fgRemoveRefPred(bFalseDest, block));

// We will convert block to BBJ_ALWAYS, so no need to keep bFalseDest up to date
}
else if (bDest->KindIs(BBJ_ALWAYS) && bDest->TargetIs(bFalseDest) && bDest->isEmpty())
{
// Optimize block -> bDest -> bFalseDest into a BBJ_ALWAYS
block->SetTrueTarget(bFalseDest);
fgAddRefPred(bFalseDest, block, fgRemoveRefPred(bDest, block));

// We will continue to use bDest, so ensure it is up to date
bDest = bFalseDest;
}

if (block->FalseTargetIs(bDest))
{
fgRemoveConditionalJump(block);
assert(block->KindIs(BBJ_ALWAYS));
Expand Down