Repository navigation
JIT: sign-extend folded 32-bit RotateLeft/RotateRight constants - #135833
Merged
Merged
Conversation
impRotateHelper folds 32-bit rotates of constants into a uint32_t and passed it to gtNewIconNode, which zero-extended it on 64-bit hosts. TYP_INT constants must be sign-extended, so a result with bit 31 set (e.g. int.RotateLeft(1, 31)) was treated as +2^31 and comparisons against it were folded incorrectly. Cast the result to int32_t. Fixes dotnet#135814 Fixes dotnet#129099 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ec7c151-8b7f-4bf9-8b1a-8c601a2965ec
|
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 unsigned test omits the multiple-use pattern needed to cover the reported Checked-build assertion.
1 open finding
What changed in this PR
Fixes JIT constant folding for 32-bit rotations whose results have the sign bit set.
Changes:
- Sign-extends folded results before creating integer constant nodes.
- Adds signed-comparison and unsigned-rotation regression tests.
Builds and tests were not run.
| File | Description |
|---|---|
| src/tests/JIT/Regression_ro_2/Runtime_135814.cs | Adds rotation regression coverage. |
| src/coreclr/jit/importercalls.cpp | Corrects folded constant representation. |
🧠 Review effort: Balanced
This was referenced Oct 15, 2026
Closed
Member
Author
|
PTAL @dotnet/jit-contrib, trivial change, no diffs |
tannergooding
approved these changes
Oct 15, 2026
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.

impRotateHelper folds 32-bit rotates of constants into a uint32_t and passed it to gtNewIconNode, which zero-extended it on 64-bit hosts. TYP_INT constants must be sign-extended, so a result with bit 31 set (e.g. int.RotateLeft(1, 31)) was treated as +2^31 and comparisons against it were folded incorrectly. Cast the result to int32_t.
Fixes #135814
Fixes #129099
No diffs