Skip to content
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

JIT: Compact newly recognized loops #97149

Merged
merged 2 commits into from
Jan 19, 2024
Merged
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
15 changes: 10 additions & 5 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4466,11 +4466,6 @@ bool Compiler::optCompactLoops()
bool changed = false;
for (FlowGraphNaturalLoop* loop : m_loops->InReversePostOrder())
{
if (!loop->GetHeader()->HasFlag(BBF_OLD_LOOP_HEADER_QUIRK))
{
continue;
}

changed |= optCompactLoop(loop);
}

Expand Down Expand Up @@ -4504,6 +4499,16 @@ bool Compiler::optCompactLoop(FlowGraphNaturalLoop* loop)
continue;
}

// If this is a CALLFINALLYRET that is not in the loop, but the
// CALLFINALLY was, then we have to leave it in place. For compaction
// purposes this doesn't really make any difference, since no codegen
// is associated with the CALLFINALLYRET anyway.
if (cur->isBBCallFinallyPairTail())
{
cur = cur->Next();
continue;
}
Comment on lines +4502 to +4510
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting case that can occur since we do not return any EH succeessors for CALLFINALLYRET; if the CALLFINALLY/CALLFINALLYRET is inside a try whose handler loops back around, then the CALLFINALLY may be part of the loop while the CALLFINALLYRET isn't. Here's an example case; red edges are EH successor edges. The CALLFINALLY is BB19 and the CALLFINALLYRET is BB20.


BasicBlock* lastNonLoopBlock = cur;
while (true)
{
Expand Down
Loading