Repository navigation
JIT: Preserve null checks in SequenceEqual VN folding - #135364
Merged
Merged
Conversation
Preserve faulting behavior for equal references with short nonempty sequences, and retain nullable calls when the length is unknown. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7219f17d-da1f-42e0-bd7c-d9eecdba5eb6
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 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 |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The behavioral JIT fix lacks targeted regression coverage for null refs, length boundaries, and evaluation order.
1 open finding
What changed in this PR
Corrects JIT folding of SpanHelpers.SequenceEqual to preserve required null-check behavior.
Changes:
- Handles zero and unknown lengths safely.
- Emits null checks for short, equal-address sequences.
- Preserves argument side effects.
| File | Description |
|---|---|
src/coreclr/jit/assertionprop.cpp |
Refines equal-VN SequenceEqual folding semantics. |
🧠 Review effort: Balanced
This was referenced Oct 7, 2026
JulieLeeMSFT
approved these changes
Oct 8, 2026
Member
Author
|
/ba-g unrelated SMPT failures |
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.

The equal-VN fold of
SpanHelpers.SequenceEqualcan returntruefor identical null refs even when the managed implementation would dereference them and throw.Preserve
GT_NULLCHECKs for short, nonempty sequences (0 < length < sizeof(nuint)), while keeping the zero-length and long-buffer shortcuts. Retain the call when the length is unknown and the refs may be null. Argument side effects remain evaluated before the null checks.