Skip to content

<xutility>: optimize _Find_unchecked for data sizes other than 1 #2379

@AlexGuteniev

Description

@AlexGuteniev

_Find_unchecked is the implementation of std::find.

Currently it is optimized for 8 bit size array elements by using memchr.

It is possible to expand this optimization for 16 bit size array elements by using wmemchr.

For greater size operands, like 32 or 64 bit, it is possible to implement the optimization either, but it takes some manual implementation.

Assuming 32 bit element, the comparison using SSE2 can be made with _mm_cmpeq_epi32. Then with _mm_movemask_epi8, mask can be extracted. If it is nonzero, countr_zero may be used to determine the position of the first match. This only requires SSE2, which is x64 baseline.

With AVX2, there are 256-bit variables available and 64 bit data sizes are possible.

The implementations should probably go to vector_algorithm.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!performanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions