Fix assertions generated by optCreateJumpTableImpliedAssertions#123240
Merged
EgorBo merged 1 commit intodotnet:mainfrom Jan 16, 2026
Merged
Fix assertions generated by optCreateJumpTableImpliedAssertions#123240EgorBo merged 1 commit intodotnet:mainfrom
EgorBo merged 1 commit intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the JIT compiler's assertion propagation optimization where incorrect assertions were being generated for switch statement default cases when the switch expression involved an offset.
Changes:
- Fixed assertion generation logic in
optCreateJumpTableImpliedAssertionsto only create range assertions for default cases when there's no offset - Added a regression test to verify the fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/assertionprop.cpp | Added condition to check offset == 0 before creating assertions for default case, with explanatory comment |
| src/tests/JIT/Regression/JitBlue/Runtime_122254/Runtime_122254.cs | Added regression test with switch statement to verify correct behavior when block value is 0 |
jakobbotsch
approved these changes
Jan 16, 2026
rosebyte
pushed a commit
that referenced
this pull request
Jan 19, 2026
) Fixes #122254 bug repro: ```c switch (X) { case 2: // ... break; case 3: // ... break; case 4: // ... break; default: // "X >= 5" assertion was created here (which is incorrect, X can be 0 or 1 as well) break; } ```
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.
Fixes #122254
bug repro: