Skip to content

Commit 9851b10

Browse files
AndyAyersMSgithub-actions
authored and
github-actions
committed
JIT: revised fix for fp division issue in profile synthesis
The previous fix #113396 could still leave us trying to evaluate 0.0/0.0, which causes an invalid FP operation exception. Make sure the divisor is non-zero.
1 parent fc27902 commit 9851b10

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/coreclr/jit/fgprofilesynthesis.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -1413,14 +1413,9 @@ void ProfileSynthesis::GaussSeidelSolver()
14131413
// Note we are using a "point" bound here ("infinity norm") rather than say
14141414
// computing the L2-norm of the entire residual vector.
14151415
//
1416-
weight_t const smallFractionOfChange = 1e-9 * change;
1417-
weight_t relDivisor = oldWeight;
1418-
if (relDivisor < smallFractionOfChange)
1419-
{
1420-
relDivisor = smallFractionOfChange;
1421-
}
1422-
1423-
weight_t const blockRelResidual = change / relDivisor;
1416+
// Avoid dividing by zero if oldWeight is very small.
1417+
//
1418+
weight_t const blockRelResidual = change / max(oldWeight, 1e-12);
14241419

14251420
if ((relResidualBlock == nullptr) || (blockRelResidual > relResidual))
14261421
{

0 commit comments

Comments
 (0)