Skip to content

Commit

Permalink
JIT: Don't run optSetBlockWeights when we have PGO data (#111764)
Browse files Browse the repository at this point in the history
Part of #107749. For PGO scenarios, we plan to rely entirely on profile synthesis to propagate profile-derived weights throughout the flowgraph. This is the first step in transitioning away from the existing weight propagation heuristics. We want to keep these around for non-PGO scenarios for now, though ideally, we'll eventually be able to replace these entirely with profile synthesis (plus branch prediction heuristics when we don't have profile data), and consolidate how the profile is maintained for PGO and non-PGO scenarios.
  • Loading branch information
amanasifkhalid authored Jan 25, 2025
1 parent a0ccbd8 commit 38b1419
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ DataFlow::DataFlow(Compiler* pCompiler)
PhaseStatus Compiler::optSetBlockWeights()
{
noway_assert(opts.OptimizationEnabled());
assert(m_dfsTree != nullptr);
const bool usingProfileWeights = fgIsUsingProfileWeights();

// Rely on profile synthesis to propagate weights when we have PGO data.
// TODO: Replace optSetBlockWeights with profile synthesis entirely.
if (usingProfileWeights)
{
// Leave breadcrumb for loop alignment
fgHasLoops = m_dfsTree->HasCycle();
return PhaseStatus::MODIFIED_NOTHING;
}

bool madeChanges = false;

assert(m_dfsTree != nullptr);
if (m_domTree == nullptr)
{
m_domTree = FlowGraphDominatorTree::Build(m_dfsTree);
Expand All @@ -59,8 +70,7 @@ PhaseStatus Compiler::optSetBlockWeights()
optFindAndScaleGeneralLoopBlocks();
}

bool firstBBDominatesAllReturns = true;
const bool usingProfileWeights = fgIsUsingProfileWeights();
bool firstBBDominatesAllReturns = true;

fgComputeReturnBlocks();

Expand Down

0 comments on commit 38b1419

Please sign in to comment.