diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index b045ef8a23e666..178b067fb46cfc 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -1389,14 +1389,9 @@ void ProfileSynthesis::GaussSeidelSolver() // Note we are using a "point" bound here ("infinity norm") rather than say // computing the L2-norm of the entire residual vector. // - weight_t const smallFractionOfChange = 1e-9 * change; - weight_t relDivisor = oldWeight; - if (relDivisor < smallFractionOfChange) - { - relDivisor = smallFractionOfChange; - } - - weight_t const blockRelResidual = change / relDivisor; + // Avoid dividing by zero if oldWeight is very small. + // + weight_t const blockRelResidual = change / max(oldWeight, 1e-12); if ((relResidualBlock == nullptr) || (blockRelResidual > relResidual)) {