-
Notifications
You must be signed in to change notification settings - Fork 5k
Optimize VectorX<T>.ConditionalSelect for constant masks #104092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@dotnet-policy-service agree |
src/coreclr/jit/gentree.cpp
Outdated
// TODO-XARCH-AVX512 Use VPBLENDM* and take input directly from K registers if cond is from | ||
// MoveMaskToVectorSpecial. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't applicable to the general query, it was specific to the CndSel lowering logic
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
@EgorBo, this should be good for secondary sign-off and merging now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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: