Repository navigation
JIT: Propagate rejectNegativeConst through lcl + cns in monotonicity check - #135851
Merged
Merged
Conversation
…check For `lcl + lcl`, `IsBinOpMonotonicallyIncreasing` requires both operands to have non-negative seeds (`rejectNegativeConst`). But when an operand was itself `lcl + cns`, the check recursed with `rejectNegativeConst = false`, so in `i += k; k = m + 2` the negative seed of `m` (-4) was accepted. `i` was treated as monotonically increasing and `i < -2` was folded to false. Fix: pass the caller's `rejectNegativeConst` through the `lcl + cns` case. No asm diffs in libraries.pmi. Fixes dotnet#134454 Co-authored-by: Copilot <[email protected]> Copilot-Session: ef747772-3030-470e-b839-f9a4fc116717
|
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.
🔵 Needs a closer look
Optimized regression execution remains unverified; human review should confirm failure before the fix and success afterward.
0 open findings
What changed in this PR
Fixes JIT monotonicity analysis for nested additions by preserving negative-seed rejection, addressing the incorrect comparison folding reported in #134454.
Changes:
- Propagates
rejectNegativeConstthrough local-plus-constant expressions. - Updates the helper declaration and call.
- Adds a regression test expecting
-3.
| File | Description |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_134454.cs |
Adds the negative-seed regression test. |
src/coreclr/jit/rangecheck.h |
Adds the flag to the helper signature. |
src/coreclr/jit/rangecheck.cpp |
Preserves the flag during recursive analysis. |
🧠 Review effort: Balanced
This was referenced Oct 15, 2026
Closed
Member
Author
|
PTAL @dotnet/jit-contrib, trivial change, a few 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 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.
For
lcl + lcl,IsBinOpMonotonicallyIncreasingrequires both operands to have non-negative seeds (rejectNegativeConst). But when an operand was itselflcl + cns, the check recursed withrejectNegativeConst = false, so ini += k; k = m + 2the negative seed ofm(-4) was accepted.iwas treated as monotonically increasing andi < -2was folded to false.Fix: pass the caller's
rejectNegativeConstthrough thelcl + cnscase. No asm diffs in libraries.pmi.Fixes #134454
A few diffs (correctness)