Repository navigation
Use SSA-based GetRange for ArrLen in OptimizeRangeCheck - #121683
Merged
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
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
Contributor
|
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++]
} |
Member
Author
it seems to be a different pattern, feel free to file an issue! |
Member
Seems like that case is already covered by #116238 |
AndyAyersMS
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #121682
Removes the bounds checks in ^
Diffs