Skip to content

vector_algorithms.cpp: further cleanup #5485

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

Conversation

AlexGuteniev
Copy link
Contributor

search_n

Generalize the first step for every element size, making the whole approach more readable and use fewer lines of code.

mismatch

Reduce element size variation. We can always compare bytewise, the division by element size would truncate the unneeded remainder length.

The 8 byte element instruction is a bit of odd ball 🎱. The SSE version has a bit higher CPU requirement (SSE4.2, not SSE2), it is a bit longer, and a bit less efficient. Still I don't think it is a performance change: I think the compiler would emit memory-operand version on AVX2 path, which does not differ in performance from the 1-byte equivalent.

minmax_element

Just more tails closer to the function where they are used. Traits are used in all functions here, tails are only for minmax_element

bitset from string

Move AVX2 exit intrinsic inside the implementation function to make the compiler emit a tail call. A perf change, though a very small one.

bitset to string

Ditto. But this time it didn't help emitting tail call. Still done for consistency.

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner May 10, 2025 12:59
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews May 10, 2025
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label May 10, 2025
@StephanTLavavej StephanTLavavej self-assigned this May 10, 2025
@StephanTLavavej
Copy link
Member

Excellent, thank you! 😻

@StephanTLavavej StephanTLavavej removed their assignment May 15, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews May 15, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews May 16, 2025
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit d6155d4 into microsoft:main May 17, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews May 17, 2025
@StephanTLavavej
Copy link
Member

🧹 🧹 🧹

@AlexGuteniev AlexGuteniev deleted the vector-algorithms-further-cleanup branch May 17, 2025 03:59
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.

2 participants