JIT: Normalize optimizations for ConditionalSelect and BlendVariable#123146
JIT: Normalize optimizations for ConditionalSelect and BlendVariable#123146tannergooding merged 8 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
3e3d69d to
9fd14b8
Compare
9fd14b8 to
6802401
Compare
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 <175728472+Copilot@users.noreply.github.com>
|
@dotnet/jit-contrib this is ready for review |
|
@kg, PTAL. This is a community PR. |
kg
left a comment
There was a problem hiding this comment.
LGTM. Any concerns @tannergooding ?
tannergooding
left a comment
There was a problem hiding this comment.
LGTM (thought I had already signed off on this one)
|
Updating CI since its been a month, should auto merge when it completes |
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