JIT: bail from optOptimizeBoolsCondBlock on GTF_UNSIGNED inputs#128928
Open
AndyAyersMS wants to merge 1 commit into
Open
JIT: bail from optOptimizeBoolsCondBlock on GTF_UNSIGNED inputs#128928AndyAyersMS wants to merge 1 commit into
AndyAyersMS wants to merge 1 commit into
Conversation
optOptimizeBoolsCondBlock folds pairs of BBJ_COND blocks of the form "(x == 0) || (x relop 0)" into a single directional comparison. Mirror the existing check at the (LT,LT)/(LT,GE) folds and bail out if either input is unsigned. Possible a fix for dotnet#128895. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens OptBoolsDsc::optOptimizeBoolsCondBlock to avoid folding specific two-block boolean patterns into a signed directional compare when either original condition node is flagged GTF_UNSIGNED, preventing SetOper from accidentally making an originally-irrelevant unsigned flag become semantically meaningful after the fold.
Changes:
- Add early bail-outs in
optOptimizeBoolsCondBlockfor the “same local” fold cases when either input comparison node is marked unsigned. - Add a JitBlue regression test that enables Tiered Compilation + Tiered PGO and checks the runtime behavior of an OR-chain that previously could miscompile.
- Add a dedicated test
.csprojenabling process isolation and setting the requiredDOTNET_*environment variables for the repro scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/coreclr/jit/optimizebools.cpp |
Adds unsigned-flag bail-outs before performing signed directional folding that uses SetOper (which preserves flags). |
src/tests/JIT/Regression/JitBlue/Runtime_128895/Runtime_128895.cs |
New regression test that drives Tier0→Tier1+PGO and validates correct boolean results for the OR-chain scenario. |
src/tests/JIT/Regression/JitBlue/Runtime_128895/Runtime_128895.csproj |
Enables process isolation and sets DOTNET_TieredCompilation/DOTNET_TieredPGO to exercise the intended JIT pipeline in test runs. |
EgorBo
approved these changes
Jun 3, 2026
Member
EgorBo
left a comment
There was a problem hiding this comment.
I feel like the entire function can be rewritten to be some sort of a table with rules like the one in RBO
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.
optOptimizeBoolsCondBlock folds pairs of BBJ_COND blocks of the form "(x == 0) || (x relop 0)" into a single directional comparison.
Mirror the existing check at the (LT,LT)/(LT,GE) folds and bail out if either input is unsigned.
Possible fix for #128895.