[release/10.0] JIT: Use native sized indices in the backend for GetElement and WithElement#119172
Merged
jeffschwMSFT merged 1 commit intodotnet:release/10.0from Aug 28, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR backports a fix from #118990 to ensure that SIMD vector indices are properly normalized to native-sized integers in the JIT backend. The issue occurs when the JIT frontend leaves 32-bit indices while the backend assumes 64-bit normalized indices, potentially causing memory corruption or segfaults if the upper bits of the index register are non-zero.
Key changes:
- Added
NormalizeIndexToNativeSizedfunction to convert indices to native-sized integers - Applied index normalization in
GetElementandWithElementoperations across x86/x64 and ARM architectures - Added assertions to verify proper index types in code generation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/lower.h | Added declaration for NormalizeIndexToNativeSized function |
| src/coreclr/jit/lower.cpp | Implemented NormalizeIndexToNativeSized function to cast or convert indices to native size |
| src/coreclr/jit/lowerxarch.cpp | Applied index normalization in x86/x64 GetElement and WithElement intrinsics |
| src/coreclr/jit/lowerarmarch.cpp | Applied index normalization in ARM GetElement intrinsic |
| src/coreclr/jit/hwintrinsiccodegenxarch.cpp | Added assertions to verify indices are native-sized during code generation |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
tannergooding
approved these changes
Aug 28, 2025
jeffschwMSFT
approved these changes
Aug 28, 2025
Member
jeffschwMSFT
left a comment
There was a problem hiding this comment.
approved. we can merge when ready
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.
Backport of #118990 to release/10.0
Customer Impact
Potential bad codegen for methods that involve indexing SIMD vectors with non-constant indices. The JIT backend assumes a 64-bit normalized index while the JIT frontend leaves a 32-bit index. If the upper bits of the register containing the index end up being non-zero, then memory corruption or segfaults/AVs can occur.
Regression
Testing
Manual inspection of codegen of the method reported in #118974. Automatic testing of this problem is hard as the register containing the index almost always ends up normalized on x64 and arm64.
Risk
Low