-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add algorithm-specific detection macros for vectorization #5801
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
Merged
StephanTLavavej
merged 33 commits into
microsoft:main
from
StephanTLavavej:vector-von-doom
Oct 29, 2025
Merged
Add algorithm-specific detection macros for vectorization #5801
StephanTLavavej
merged 33 commits into
microsoft:main
from
StephanTLavavej:vector-von-doom
Oct 29, 2025
Conversation
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
tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
AlexGuteniev
approved these changes
Oct 24, 2025
_VECTORIZED_FIND_LAST_NOT_OF guarded __std_find_last_not_ch_pos_1 which calls _Finding::_Find_last_pos_impl which calls _Finding::_Find_last_impl _VECTORIZED_FIND_LAST guards __std_find_last_trivial_1 which calls _Finding::_Find_last_impl
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
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.
Almost ready to approve, just want to understand a few things.
davidmrdavid
approved these changes
Oct 28, 2025
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.
No functional change for users; this keeps
_USE_STD_VECTOR_ALGORITHMSas our documented control macro.To prepare for adding ARM64 and eventually ARM64EC vectorized implementations, this begins by adding a layer of architecture-specific detection macros. (This layer isn't strictly necessary, but it makes life easier because it (1) allows the control macro to shut everything down, (2) deals with how ARM64EC defines both
_M_ARM64ECand_M_X64, and (3) centralizes how x64/x86 vectorization is always paired.)Then this introduces algorithm-specific detection macros. This makes connections throughout the codebase easier to understand, because a given vectorized algorithm needs declarations of separately compiled functions (
__std_meow_4), a wrapper template (_Meow_vectorized), callsites, and occasionally helper type traits (_Vector_alg_in_meow_is_safe). This will also make it significantly easier to implement algorithms one at a time for ARM64, since this PR is decomposing what was previously a monolithic mode.The
_VECTORIZED_MEOWmacros are named to avoid confusion with any control macros (we usually use the_HAS_BLAHor_USE_BLAHpatterns for control). They're deliberately the mirror image of the_Meow_vectorizedwrappers, to further avoid confusion.In simple cases, the macros are 1:1 with the wrapper templates. However, there are several "algorithm families" implemented in
vector_algorithms.cpp, like theminmaxandminmax_elementfamilies and the variousfindvariants. I tried to introduce macros that corresponded to these algorithm families, since that's how they'll be implemented (and there would be no benefit to introducing an even finer-grained system).There are a couple of places where I had to slightly adjust
if constexprlogic to handle theminmaxandminmax_elementfamilies potentially being variously active.Finally, while removing the old monolithic macro, I allowed the code to expand to empty
extern "C" { ... }blocks when no vectorization is active, because this is harmless and avoids cluttering up the code with even more verbosity.