Repository navigation
Preserve range facts for unpromoted span lengths - #136865
Open
NinoFloris wants to merge 1 commit into
Open
NinoFloris wants to merge 1 commit into
NinoFloris wants to merge 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
2 tasks
Mark nonnegative span-length field and indirection VNs as checked bounds, matching promoted locals. Generate nonnegative assertions for local field loads so existing symbolic range analysis can eliminate redundant Slice checks. Annotate in the local-field and indirection VN handlers so unrelated nodes do not pay for the extra test. Keep ordinary local-variable assertion handling on its original fast path, and skip nonnegative assertion generation during local propagation. Recognize the loads structurally with IntegralRange::ForNode, as the existing indirection assertion already did. The VN-based half of GenTree::IsNeverNegative cannot succeed for these load shapes in practice and costs a VN walk on every int-typed load, which on 32-bit targets includes pointer-sized loads. Replaying the windows x64 libraries PMI collection with and without CSE of address-exposed locals produced no differences between the two forms across 331,945 contexts, while both change the same 14 methods relative to main. Look up the value number's function once in IsVNNeverNegative. The array length test, the hardware intrinsic test and the function switch each fetched it separately. Add an unpromoted-span regression covering the signed guard and writes that invalidate the guarded length.
NinoFloris
force-pushed
the
bounds-elimination/span-length-range-facts
branch
from
November 3, 2026 02:40
5876efe to
70defdd
Compare
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Promoted span-length locals are marked as nonnegative and their VNs as checked bounds. Equivalent field loads don’t receive all the same annotations, leaving redundant Slice checks when the span remains in memory or is passed implicitly by reference.
Mark recognized span-length field and indirection VNs as checked bounds, and generate nonnegative assertions for local-field loads. This lets the existing range analysis eliminate the redundant unsigned check after a signed guard.
Add coverage with struct promotion disabled, including intervening writes that must prevent elimination.
Complements recently merged changes in: #136615