Skip to content

Commit

Permalink
JIT: Allow flow edges to be considered more than once by 3-opt (dotne…
Browse files Browse the repository at this point in the history
…t#109534)

Part of dotnet#107749. Follow-up to dotnet#103450. If 3-opt fails to create fallthrough on an edge because it isn't initially profitable, allow the edge to be considered again, in case future moves make it profitable.
  • Loading branch information
amanasifkhalid authored Dec 4, 2024
1 parent 73877b4 commit 1361d1e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5095,7 +5095,6 @@ void Compiler::ThreeOptLayout::ConsiderEdge(FlowEdge* edge)
return;
}

edge->markVisited();
BasicBlock* const srcBlk = edge->getSourceBlock();
BasicBlock* const dstBlk = edge->getDestinationBlock();

Expand Down Expand Up @@ -5145,6 +5144,7 @@ void Compiler::ThreeOptLayout::ConsiderEdge(FlowEdge* edge)
return;
}

edge->markVisited();
cutPoints.Push(edge);
}

Expand Down Expand Up @@ -5322,7 +5322,7 @@ bool Compiler::ThreeOptLayout::RunGreedyThreeOptPass(unsigned startPos, unsigned
assert(startPos < endPos);
bool modified = false;

JITDUMP("Using greedy strategy for finding cut points.\n");
JITDUMP("Running greedy 3-opt pass.\n");

// Initialize cutPoints with candidate branches in this section
for (unsigned position = startPos; position <= endPos; position++)
Expand All @@ -5337,7 +5337,7 @@ bool Compiler::ThreeOptLayout::RunGreedyThreeOptPass(unsigned startPos, unsigned
while (!cutPoints.Empty())
{
FlowEdge* const candidateEdge = cutPoints.Pop();
assert(candidateEdge->visited());
candidateEdge->markUnvisited();

BasicBlock* const srcBlk = candidateEdge->getSourceBlock();
BasicBlock* const dstBlk = candidateEdge->getDestinationBlock();
Expand Down

0 comments on commit 1361d1e

Please sign in to comment.