-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vectorize find_first_of
for 4 and 8 byte elements
#4587
Conversation
On the other hand, despite having more code, it would be an uniform approach. |
`__fallback` => `_Fallback` `__shuffle_step` => `_Shuffle_step` `__shuffle_impl` => `_Shuffle_impl` `__pcmpestri_impl` => `_Impl_pcmpestri` `__4_8_impl` => `_Impl_4_8`
This reverts commit 1cae60f.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for finding so many ways to improve performance! 🕵️ 💡 🚀 |
The specialized approach shuffles the needle so that every element is on every place and compares it with the haystack part. Then
or
s all comparison results to find the lowest index match, then if there's a match returns it.The generic approach finds a haystack element in the needle, it is like
find
with reversed haystack/needle, but instead ofvpmovmskb
and checking that index and computing offset, we havevptest
, as we don't need the index.Looks like we will have way better results if specialized approach is generalized,, instead of having different and simpler generic approach. But the complexity would grow.
If only the generic approach is used, the complexity would be reduced, but the performance for small needles would be worse, the generic approach for small needles and 64-bit elements even loses to the scalar implementation.
Benchmark results
Before:
After: