Optimize VectorX<T>.ConditionalSelect for constant masks#104092
Merged
tannergooding merged 10 commits intodotnet:mainfrom Jul 4, 2024
Merged
Optimize VectorX<T>.ConditionalSelect for constant masks#104092tannergooding merged 10 commits intodotnet:mainfrom
tannergooding merged 10 commits intodotnet:mainfrom
Conversation
This adds a check in the JIT for constant masks (`GT_CNS_VEC`, everything else gets lowered to it) and enables optimization to `BlendVariable` (`(v)pblendvb` instruction). This currently does not work for masks loaded from an array in a field/variable. Also this optimization is not triggered for platforms supporting AVX512F(/VL?) since it gets optimized earlier to `vpternlogd` instruction.
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
Author
|
@dotnet-policy-service agree |
EgorBo
reviewed
Jun 27, 2024
EgorBo
reviewed
Jun 27, 2024
EgorBo
reviewed
Jun 27, 2024
This was referenced Jun 27, 2024
Open
src/coreclr/jit/gentree.cpp
Outdated
Comment on lines
29487
to
29488
| // TODO-XARCH-AVX512 Use VPBLENDM* and take input directly from K registers if cond is from | ||
| // MoveMaskToVectorSpecial. |
Member
There was a problem hiding this comment.
This comment isn't applicable to the general query, it was specific to the CndSel lowering logic
tannergooding
approved these changes
Jun 29, 2024
This was referenced Jul 1, 2024
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
tannergooding
approved these changes
Jul 3, 2024
Member
|
@EgorBo, this should be good for secondary sign-off and merging now |
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.
Resolves #104001.
I’ve also realized that it is not possible to implement this for arrays as I’ve originally intended since we have no immutability guarantees, so instead I’ve made sure it gets optimized with
ReadOnlySpan<T>property and staticVectorX<T>field.Example:
Old codegen:
New codegen: