Open
Description
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
- [libc++] Vectorize mismatch #73255 -
search
(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 - [libc++] Optimize ranges::minmax #87335 -
minmax_element
- Vectorize minmax_element. #112397 -
lexicographical_compare
: Should usemismatch
for the actual vectorization, but only forward to it if it's known to vectorize -
lexicographical_compare_three_way
: same aslexicographical_compare
-
replace_if
autovectorized since [LV] Support generating masks for switch terminators. #99808
Should 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 ranges
Shouldn'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 [SCEV] Support addrec in right hand side in howManyLessThans #92560