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
JIT: Improve and fix StaysWithinManagedObject (#105108)
- For string accesses we also produce `ARR_ADDR`, so we must take care
to use `GenTreeArrAddr::GetFirstElemOffset` instead of hardcoding
`OFFSETOF__CORINFO_Array__data`
- There are cases where VN is fully able to prove that bound <
ARR_LENGTH(vn), specifically when the array is stored in a static
readonly field. In those cases everything reduces to constants, so
allow VN to try to prove it but fall back to our manual logic
otherwise.
- Rephrase the fallback as a VN test as well. In a standard `for (;i <
arr.Length;)` loop we have a bound on the backedge of the shape
`ARR_LENGTH(array) - 1`. The previous strategy was to syntactically
check if the LHS was such an array length on the same array as the
base of the add recurrence.
Instead of doing that, we can ask more generally for any shape `x - c`
whether we know that `x <= ARR_LENGTH(array)`. In the usual case of `x
== ARR_LENGTH(array)` this is trivially true and VN knows that.
However, there are other cases where this is provable by RBO due to a
dominating compare; particularly loop cloning introduces these
dominating compares when cloning loops of the shape `for (; i < n;)`.
This fixes#105087.
0 commit comments