Remove 'rng.LowerLimit().AddConstant(cns);'#120233
Merged
EgorBo merged 2 commits intodotnet:mainfrom Sep 30, 2025
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
jakobbotsch
approved these changes
Sep 30, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the JIT compiler's assertion propagation range analysis where a constant was being added twice to the lower bound of a range. The fix removes a redundant line that was mistakenly adding the constant to the lower limit before the actual range check logic.
- Removes duplicate constant addition to range lower bound in assertion propagation
- Adds regression test to prevent future occurrences of this bug
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/assertionprop.cpp | Removes the redundant rng.LowerLimit().AddConstant(cns); line that was incorrectly modifying the range before validation |
| src/tests/JIT/Regression/JitBlue/Runtime_119710/Runtime_119710.cs | Adds regression test case that would fail with the bug present |
| src/tests/JIT/Regression/JitBlue/Runtime_119710/Runtime_119710.csproj | Project file for the regression test |
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.
Fixes #119710
When we want to see if the expression
(X + CNS)is never negative, we get X's range and then Add CNS to it (for both lower and upper bound). It seems like we add the lower one twice because it's supposed to be done only once here:seems to be some copy-paste mistake and I'm surprised it it showed up only now (was exposed by #119474)
Surprisingly, there are jit-diff improvements from not adding the constant twice to the lower bound: diffs