Open philnik777 opened 8 months ago
@philnik777 std::reverse auto-vectorized by #92560
@mrdaybird thanks, that's great! I've updated the list.
FYI: vectorization of find_first_of
for AArch64 is implemented in https://github.com/llvm/llvm-project/pull/101976
There are quite a few algorithms which can be vectorized, or one should at least look into doing so. This issue lists all the algorithms which I think can be vectorized (and a few that shouldn't be with explanations).
To be vectorized:
find
(already done partially by forwarding to{w,}memchr
)find_end
find_first_of
(possibly not worth it, since clang does it automatically in some cases)adjacent_find
mismatch
- #73255search
(not checked whether it actually makes sense)search_n
remove
(requires efficient compressstore)remove_copy
(requires efficient compressstore)unique
(might require efficient compressstore)unique_copy
(might require efficient compresstore)is_sorted_until
includes
min_element
max_element
minmax
(range overload): Should first be checked whether it can be rewritten to allow auto-vectorization - #87335minmax_element
lexicographical_compare
: Should usemismatch
for the actual vectorization, but only forward to it if it's known to vectorizelexicographical_compare_three_way
: same aslexicographical_compare
replace_if
autovectorized since https://github.com/llvm/llvm-project/pull/99808Should be checked whether they can be vectorized:
set_union
set_intersection
set_difference
set_symmetric_difference
merge
rotate
is usingmemmove
when possible, but may make sense to optimize for small rangesShouldn't be vectorized:
contains
: forwards tofind
, which should be vectorized insteadcount
: is auto-vectorizedequal
: Already forwards tomemcmp
for trivially equality comparable types and doesn't seem worth it for floatsfold
(and friends): is auto-vectorizedcopy
(and friends): can be forwarded tomemmove
swap_ranges
: is auto-vectorizedreplace
(and friends): is auto-vectorizedfill
(and friends): is auto-vectorizedreverse_copy
: is auto-vectorizedrotate_copy
: is forwarded to twomemmove
calls if possibleshift_left
/shift_right
: is forwarded tomemmove
if possibleis_sorted
: forwards tois_sorted_until
, which should be vectorized insteadmin
,max
(range overload): is auto-vectorizedreverse
: auto-vectorized since https://github.com/llvm/llvm-project/pull/92560