-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix bug in RangeOps::ShiftRight #123794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix bug in RangeOps::ShiftRight #123794
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
| } | ||
|
|
||
| // Check if the range represents a single constant value. Example: [7..7] | ||
| bool IsSingleConstValue(int* pConstVal) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two PRs introduced similar helpers, removed one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes an incorrect range computation in JIT range analysis for right-shift operations (RangeOps::ShiftRight), addressing #123790 and adding a regression test to prevent recurrence.
Changes:
- Add a JIT regression test for the reported shift/comparison miscompile.
- Rework
RangeOps::ShiftRightto compute bounds using opposite shift-count endpoints (lower usesr2.UpperLimit, upper usesr2.LowerLimit) when the shift-count range is constant and within[0..31]. - Remove
Range::IsSingleConstValueusage in favor of the existingRange::IsSingleValueConstant.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/JIT/Regression/JitBlue/Runtime_123790/Runtime_123790.cs | Adds an xUnit regression test for the miscompile scenario from #123790. |
| src/coreclr/jit/rangecheck.h | Updates range computation logic for ShiftRight and replaces IsSingleConstValue references with IsSingleValueConstant. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
|
/azp run Fuzzlyn |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
PTAL @jakobbotsch @dotnet/jit-contrib fix for ShiftRight (see description). No diffs. |
Fixes #123790
For e.g.
[0..65535] >> [0..31]I didn't realize I need to swap lower and upper bound for r2, so the result should be:[0 >> 31 .. 65535 >> 0], not[0 >> 0 .. 65535 >> 31]No diffs