Skip to content

Commit 789aca1

Browse files
Fix setting weight for inverted loop condition block (#74444)
In stress scenarios with inconsistent weights, it was possible to change the condition weight from zero to non-zero without resetting the "rarely run" bit. Use `inheritWeight()` to set the weight, which handles this case. Fixes #74218
1 parent 06473b7 commit 789aca1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/coreclr/jit/optimizer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5063,11 +5063,12 @@ bool Compiler::optInvertWhileLoop(BasicBlock* block)
50635063
//
50645064
if (allProfileWeightsAreValid)
50655065
{
5066-
// Update the weight for bTest
5066+
// Update the weight for bTest. Normally, this reduces the weight of the bTest, except in odd
5067+
// cases of stress modes with inconsistent weights.
50675068
//
50685069
JITDUMP("Reducing profile weight of " FMT_BB " from " FMT_WT " to " FMT_WT "\n", bTest->bbNum, weightTest,
50695070
weightNext);
5070-
bTest->bbWeight = weightNext;
5071+
bTest->inheritWeight(block->bbNext);
50715072

50725073
// Determine the new edge weights.
50735074
//

0 commit comments

Comments
 (0)