Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@StephanTLavavej
Copy link
Member

@StephanTLavavej StephanTLavavej commented Oct 24, 2025

No functional change for users; this keeps _USE_STD_VECTOR_ALGORITHMS as 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_ARM64EC and _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_MEOW macros are named to avoid confusion with any control macros (we usually use the _HAS_BLAH or _USE_BLAH patterns for control). They're deliberately the mirror image of the _Meow_vectorized wrappers, 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 the minmax and minmax_element families and the various find variants. 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 constexpr logic to handle the minmax and minmax_element families 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.

@StephanTLavavej StephanTLavavej requested a review from a team as a code owner October 24, 2025 13:08
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Oct 24, 2025
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Oct 24, 2025
@StephanTLavavej StephanTLavavej changed the title Add architecture-specific detection macros for vectorization Add algorithm-specific detection macros for vectorization Oct 24, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews 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
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

Copy link
Member

@davidmrdavid davidmrdavid left a 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.

@StephanTLavavej StephanTLavavej moved this from Final Review to Merging in STL Code Reviews Oct 28, 2025
@StephanTLavavej StephanTLavavej merged commit 7dff4d7 into microsoft:main Oct 29, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Oct 29, 2025
@StephanTLavavej StephanTLavavej deleted the vector-von-doom branch October 29, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants