Skip to content

Commit 5de69e8

Browse files
committed
JIT: revised fix for fp division issue in profile synthesis
The previous fix dotnet#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 b90e4e3 commit 5de69e8

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
@@ -1389,14 +1389,9 @@ void ProfileSynthesis::GaussSeidelSolver()
13891389
// Note we are using a "point" bound here ("infinity norm") rather than say
13901390
// computing the L2-norm of the entire residual vector.
13911391
//
1392-
weight_t const smallFractionOfChange = 1e-9 * change;
1393-
weight_t relDivisor = oldWeight;
1394-
if (relDivisor < smallFractionOfChange)
1395-
{
1396-
relDivisor = smallFractionOfChange;
1397-
}
1398-
1399-
weight_t const blockRelResidual = change / relDivisor;
1392+
// Avoid dividing by zero if oldWeight is very small.
1393+
//
1394+
weight_t const blockRelResidual = change / max(oldWeight, 1e-12);
14001395

14011396
if ((relResidualBlock == nullptr) || (blockRelResidual > relResidual))
14021397
{

0 commit comments

Comments
 (0)