JIT: Normalize optimizations for ConditionalSelect and BlendVariable#123146
Open
saucecontrol wants to merge 7 commits intodotnet:mainfrom
Open
JIT: Normalize optimizations for ConditionalSelect and BlendVariable#123146saucecontrol wants to merge 7 commits intodotnet:mainfrom
saucecontrol wants to merge 7 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
3e3d69d to
9fd14b8
Compare
9fd14b8 to
6802401
Compare
saucecontrol
commented
Jan 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR normalizes and consolidates optimizations for ConditionalSelect and BlendVariable intrinsics on x86/x64 architectures. The changes enable several new optimization patterns and refactor existing code to share common logic between similar operations.
Changes:
- Adds constant mask folding for
BlendVariableintrinsics (all zeros → select first operand, all ones → select second operand) - Enables folding of
ConvertVectorToMask(CNS_VEC)to constant masks at lowering time - Consolidates blend-with-zero optimizations into
AND/AND_NOToperations across bothConditionalSelectandBlendVariable - Refactors mask inversion logic into a reusable
TryInvertMaskhelper function to reduce code duplication
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/valuenum.cpp | Adds value numbering optimizations for BlendVariable intrinsics with constant masks |
| src/coreclr/jit/rationalize.cpp | Removes obsolete small type normalization logic for BlendVariable |
| src/coreclr/jit/lowerxarch.cpp | Adds lowering optimizations for BlendVariable/ConvertVectorToMask, refactors mask inversion into TryInvertMask helper, and consolidates ConditionalSelect lowering |
| src/coreclr/jit/lower.h | Adds declaration for new TryInvertMask helper method |
| src/coreclr/jit/gentree.cpp | Fixes comment typo and adds constant folding for BlendVariable in morph phase |
Co-authored-by: Copilot <[email protected]>
Member
Author
|
@dotnet/jit-contrib this is ready for review |
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.
This fills in some optimizations present for
ConditionalSelectbut notBlendVariableand vice-versa on xarch.Enables folding for
BlendVariablewith constant mask.Folds
ConvertVectorToMask(CNS_VEC)toCNS_MASKEnables EVEX embedded zero in more cases.
Optimizes blend with zero to AND/ANDN in more cases
More improvements in the full diffs