You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) loop hoisting reorders exceptions when an earlier throwing candidate is rejected as unprofitable #134937
LICM hoists a / b into the preheader but leaves the earlier arr.Length null check in the loop, because hoisting it isn't profitable. The program then throws DivideByZeroException instead of NullReferenceException.
No. .NET 8, 9, 10, 11 RC2, and main all print DivideByZeroException.
Notes
HoistVisitor::PostOrderVisit marks ARR_LENGTH(arr) as hoistable, so m_canHoistSideEffects stays true. optHoistCandidate then rejects that candidate as unprofitable ("tree cost too low"). The next tree, a / b + c, isn't blocked by the GTF_EXCEPT ordering check and is hoisted above the null check that stays in the loop. A throwing candidate that is rejected should act as an exception-ordering barrier.
Activity
dotnet-policy-service commentedon Sep 30, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
jakobbotsch commentedon Sep 30, 2026
Is this different from #133585 ? (That one was already fixed, so probably?)
JIT: preserve exception order after hoist rejection (dotnet#137118)