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) SIMD GetElement(int) range check is reordered before an earlier-evaluated "abc"[i] bounds check in call arguments #137637
In Callee("abc"[i], v.GetElement(j) * ...) the string index must throw IndexOutOfRangeException first when both i and j are out of range. The JIT reorders the arguments so Vector128<int>.GetElement(j) throws ArgumentOutOfRangeException first, violating C# left-to-right evaluation order.
The GetElement(j) check comes before the "abc"[i] check:
cmpedx,4 ; v.GetElement(j)jae SHORT G_M51568_IG05 ; -> CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION ...cmpecx,3 ; "abc"[i]jae SHORT G_M51568_IG04 ; -> CORINFO_HELP_RNGCHKFAIL
Regression?
No, reproduces on every runtime checked: 8.0.31, 9.0.20, 10.0.12, 10.0.15, 11.0.0-rc.2, 11.0.0 and main (7bbe3a812f7). .NET 7 and older were not checked.
Notes
GenTree::OperExceptions (case GT_BOUNDS_CHECK, gentree.cpp) returns IndexOutOfRangeException for every bounds check, including SIMD GetElement ones with gtThrowKind == SCK_ARG_RNG_EXCPN, which actually throw ArgumentOutOfRangeException.
CallArgs::ArgsComplete (morph.cpp) then sees both args as throwing the same single exception and lets cost-based SortArgs reorder them (inferred from source, not confirmed with a JitDump).
Possible fix: return a distinct exception flag for SCK_ARG_RNG_EXCPN bounds checks.
Activity
dotnet-policy-service commentedon Nov 16, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: Report precise exceptions for non-IndexOutOfRange bounds checks (d…