Skip to content

Conversation

AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented May 22, 2025

Follow up for #5519

  1. Scope guard for multiple return. This pattern is used in other places where we have multiple return.
  2. Drop _bittestandreset. The compiler emits btc for the ^= 1 << n pattern, which has the same performance as btr for _bittestandreset.
    • For search could also use _Bingo &= _Bingo - 1, or _blsr_u32, but there's not enough evidence in significant enough performance advantage to use this
    • For find_end could try _bzhi_u32, but didn't even bother, here the expectation is even lower.
  3. Always use unsigned 32-bit for bit masks from movemask*. Always 32 bit because internally there is 32-bit destination register, always unsigned because bitmask.
    • Still int for cmpestr* masks, it is compile time, and only few bits, and intrinsic takes int
    • In some places the cast to other bit width is needed, it is kept there

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner May 22, 2025 20:55
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews May 22, 2025
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label May 22, 2025
@StephanTLavavej StephanTLavavej changed the title Clean up vector_aglorithms.cpp again: unsigned bit manipulation, scope guard for multiple return Clean up vector_algorithms.cpp again: unsigned bit manipulation, scope guard for multiple return May 22, 2025
@StephanTLavavej StephanTLavavej self-assigned this May 22, 2025
@StephanTLavavej StephanTLavavej removed their assignment May 28, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews May 28, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews May 28, 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 0bde434 into microsoft:main May 28, 2025
48 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews May 28, 2025
@StephanTLavavej
Copy link
Member

🧹 🧹 🧹

@AlexGuteniev AlexGuteniev deleted the bit-manipulation branch May 29, 2025 04:45
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