<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/84663>84663</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] Vectorize all the algorithms
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++,
            performance
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            philnik777
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          philnik777
      </td>
    </tr>
</table>

<pre>
    There are quite a few algorithms which can be vectorized, or one should at least look into doing so. This lists 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` - #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)
- [ ] `reverse`
- [ ] `is_stored_until`
- [ ] `includes`
- [ ] `min_element`
- [ ] `max_element`
- [ ] `minmax` (range overload): Should first be checked whether it can be rewritten to allow auto-vectorization
- [ ] `minmax_element`
- [ ] `lexicographical_compare`: Should use `mismatch` for the actual vectorization, but only forward to it if it's known to vectorize
- [ ] `lexicographical_compare_three_way`: same as `lexicographical_compare`

Should be checked whether they can be vectorized:
- [ ] `set_union`
- [ ] `set_intersection`
- [ ] `set_difference`
- [ ] `set_symmetric_difference`
- [ ] `merge`
- [ ] `rotate` is using `memmove` when possible, but may make sense to optimize for small ranges

Shouldn't be vectorized:
- `contains`: forwards to `find`, which should be vectorized instead
- `count`: is auto-vectorized
- `equal`: Already forwards to `memcmp` for trivially equality comparable types and doesn't seem worth it for floats
- `fold` (and friends): is auto-vectorized
- `copy` (and friends): can be forwarded to `memmove`
- `swap_ranges`: is auto-vectorized
- `replace` (and friends): is auto-vectorized
- `fill` (and friends): is auto-vectorized
- `reverse_copy`: is auto-vectorized
- `rotate_copy`: is forwarded to two `memmove` calls if possible
- `shift_left`/`shift_right`: is forwarded to `memmove` if possible
- `is_sorted`: forwards to `is_sorted_until`, which should be vectorized instead
- `min`, `max` (range overload): is auto-vectorized

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykV01v4zgM_TXOhWjhKF_NIYd-oMCed7DXQJHpmFN9uCJdN_PrF7KdNG2ddnYWKNrCpqj3KPI9WTPT3iNussVdplRdkfX0tFqtMqWyxcNEN1KFuHl7PtmF4rD5UWFE0BHhuSFB0FBiC9ruQySpHENbkanAaA87hBc0EiL9wiJT9xAiBI_AVWhsAVrAomYBG8ITkJcARSC_Bw7X8KMiBkssDMTc4PC_thakws_7_QVSkX_6vC9k6kb7YsAplZZhf5-plaTYlqQCfK2t9looeM7U-jrLH7L8tv_9I3ygMhteXEG2uINs8QDZMi_JF9ky7_azEXVxgCKxrXUU0tYeYHeAMsRWxyKxlJBWZau7NlP32erBoTNVTI_U-kL6LXZbXHpbUmTZhnJAUQdm2tkD-CDQhigVkKRjYPIGwVjt91AEZCAB3UhwWsh0SMkDB4dgNCOP49HFT23Qy3bgPRLiiJ0WUyU8V5Cp2WqmFouRQEYd-7BM3SS0pkLzhAW0FUqFsQNopOmwOf2EDIyecRxZn23rx0FFdOEFh70iPjcUkQHLkgyhFzDB1RGZWUK8sEGfYmtCffhfeRpPz80RiqN9JTAk-pM853i-S_YVtxeMjOO1I952S4tt44XshSBvbFMgX-oJv0WLDr1cCNCv3wSQd_r1WHjt9wjhBaMNukiUZrfwd68v3TikyR3ppkEmIraRRNCnadTWhrYbhKvjrHd6cBHD1zgtvpIJ-6jrKk3VNtVex66ybxgbxo-TUobYS1zX8PAeirqHXSMQvD1pSYJOAlR2071iePKh7QidFOv30W2liojbVh8GnKwdguZvCJ2J5UBspOxS4WHEF0bFlFG2jU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