Skip to content

JIT: Remove remaining BBJ_COND fallthrough fixups #99271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 2 additions & 16 deletions src/coreclr/jit/fgehopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,28 +2103,14 @@ void Compiler::fgTailMergeThrowsFallThroughHelper(BasicBlock* predBlock,
assert(predBlock->KindIs(BBJ_COND));
assert(predBlock->FalseTargetIs(nonCanonicalBlock));

BasicBlock* const newBlock = fgNewBBafter(BBJ_ALWAYS, predBlock, true);

JITDUMP("*** " FMT_BB " now falling through to empty " FMT_BB " and then to " FMT_BB "\n", predBlock->bbNum,
newBlock->bbNum, canonicalBlock->bbNum);
JITDUMP("*** " FMT_BB " false target is now " FMT_BB "\n", predBlock->bbNum, canonicalBlock->bbNum);

// Remove the old flow
fgRemoveRefPred(predEdge);

// Wire up the new flow
FlowEdge* const falseEdge = fgAddRefPred(newBlock, predBlock, predEdge);
FlowEdge* const falseEdge = fgAddRefPred(canonicalBlock, predBlock, predEdge);
predBlock->SetFalseEdge(falseEdge);

FlowEdge* const newEdge = fgAddRefPred(canonicalBlock, newBlock, predEdge);
newBlock->SetTargetEdge(newEdge);

// If nonCanonicalBlock has only one pred, all its flow transfers.
// If it has multiple preds, then we need edge counts or likelihoods
// to figure things out.
//
// For now just do a minimal update.
//
newBlock->inheritWeight(nonCanonicalBlock);
}

//------------------------------------------------------------------------
Expand Down
16 changes: 0 additions & 16 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4995,22 +4995,6 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh
{
ehUpdateLastBlocks(bNext, bDest);
}

// Add fall through fixup block, if needed.
//
if (bDest->KindIs(BBJ_COND) && !bDest->NextIs(bDest->GetFalseTarget()))
{
BasicBlock* const bDestFalseTarget = bDest->GetFalseTarget();
BasicBlock* const bFixup = fgNewBBafter(BBJ_ALWAYS, bDest, true);
bFixup->inheritWeight(bDestFalseTarget);

fgRemoveRefPred(bDest->GetFalseEdge());
FlowEdge* const falseEdge = fgAddRefPred(bFixup, bDest);
bDest->SetFalseEdge(falseEdge);

FlowEdge* const newEdge = fgAddRefPred(bDestFalseTarget, bFixup);
bFixup->SetTargetEdge(newEdge);
}
}
}

Expand Down