-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use SSA-based GetRange for ArrLen in OptimizeRangeCheck #121683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the range check optimization by adding a fallback mechanism to determine array length using SSA-based analysis when assertion-based lookups fail. This enables removal of bounds checks in more scenarios, particularly for patterns involving index-from-end (^) operations.
Key Changes
- Adds SSA-based range analysis as a fallback when assertion-based array length lookup fails
- Uses the existing
GetRangeWorkermethod to compute array length ranges when faster methods don't find a constant length
|
Can you check does this also handle patterns like: var buffer = new T[rows.Length];
var count = 0;
for (var i = 0; i < rows.Length; i++)
{
if (predicate(rows[i])) buffer[count++] = rows[i]; // current there's bound check for buffer[count++]
} |
it seems to be a different pattern, feel free to file an issue! |
Seems like that case is already covered by #116238 |
Closes #121682
Removes the bounds checks in ^
Diffs