Skip to content

Commit 67604d3

Browse files
JIT: Set edge likelihoods during patchpoint transformation (#97897)
Fixes #97892. During patchpoint expansion, make sure to set edge likelihoods for transformed blocks.
1 parent b94a82d commit 67604d3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/coreclr/jit/patchpoint.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ class PatchpointTransformer
151151

152152
helperBlock->SetFlags(BBF_BACKWARD_JUMP | BBF_NONE_QUIRK);
153153

154-
compiler->fgAddRefPred(helperBlock, block);
155-
compiler->fgAddRefPred(remainderBlock, helperBlock);
154+
FlowEdge* const falseEdge = compiler->fgAddRefPred(helperBlock, block);
155+
FlowEdge* const trueEdge = compiler->fgGetPredForBlock(remainderBlock, block);
156+
trueEdge->setLikelihood(HIGH_PROBABILITY / 100.0);
157+
falseEdge->setLikelihood((100 - HIGH_PROBABILITY) / 100.0);
158+
159+
FlowEdge* const newEdge = compiler->fgAddRefPred(remainderBlock, helperBlock);
160+
newEdge->setLikelihood(1.0);
156161

157162
// Update weights
158163
remainderBlock->inheritWeight(block);

0 commit comments

Comments
 (0)