Fix to Jit32 test b46659.exe failure.
Here is the git hub issue: https://github.com/dotnet/coreclr/issues/4547
The repro case is
i = -111
while ( i > 0)
{
// another nested loop goes here
}
return 100
After assertionProp, due to while loop condition lot of blocks/stmts get deleted as unreachable but optLoopCount is never decremented. Later when optLoopCodeMotion() gets called, it iterates through optLoopTable[] and tries to access head
if ((loopRmv & loopBit) ||
tail == 0 ||
head->bbTreeList == 0 )
Since entire method reduces to a single basic block, head will be nullptr and accessing head->bbTreeList is leading to an AV.
Fix: As a safe fix for RTM, also check whether head is nullptr.
[tfs-changeset: 1605919]
Commit migrated from https://github.com/dotnet/coreclr/commit/
3bb9ddf1c6318655d9e6f46f29af02e0648fcebc