diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 4deb904b989898..094a116b7e8a02 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -5074,11 +5074,12 @@ bool Compiler::optInvertWhileLoop(BasicBlock* block) // if (allProfileWeightsAreValid) { - // Update the weight for bTest + // Update the weight for bTest. Normally, this reduces the weight of the bTest, except in odd + // cases of stress modes with inconsistent weights. // JITDUMP("Reducing profile weight of " FMT_BB " from " FMT_WT " to " FMT_WT "\n", bTest->bbNum, weightTest, weightNext); - bTest->bbWeight = weightNext; + bTest->inheritWeight(block->bbNext); // Determine the new edge weights. //