Add initial version of {Last}IndexOfAnyExcept#67941
Conversation
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @dotnet/area-system-memory Issue DetailsThese are functional but not vectorized. At least some of these should be vectorized for at least some data types subsequently, but that's a more intensive change. Once that's in, we can update a few places to use these, e.g. Regex should end up using any of the overloads that are vectorized. Fixes #28795
|
These are functional but not vectorized. At least some of these should be vectorized for at least some data types subsequently, but that's a more intensive change. Once that's in, we can update a few places to use these, e.g. Regex should end up using any of the overloads that are vectorized.
c0ea74e to
19841f4
Compare
src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs
Outdated
Show resolved
Hide resolved
| /// </returns> | ||
| public static int IndexOfAnyExcept<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T> | ||
| { | ||
| switch (values.Length) |
There was a problem hiding this comment.
@EgorBo do we still have limitations around inlining switch statements or was that one of the things that was minimally fixed up?
| return IndexOfAnyExcept(span, values[0], values[1]); | ||
|
|
||
| case 3: | ||
| return IndexOfAnyExcept(span, values[0], values[1], values[2]); |
There was a problem hiding this comment.
The JIT doesn't look to elide the bounds checks here. It does if you use an if (values.Length == 3) (etc).
It also reduces it down to a single check if you grab values[2], values[1], values[0], but that's still 1 more check than using if
There was a problem hiding this comment.
The JIT doesn't look to elide the bounds checks here
I could have sworn it did, but I just re-checked, and you're right, it doesn't.
I'll address that subsequently, unless Egor gets there first and fixes the JIT here :)
* Add initial version of {Last}IndexOfAnyExcept
These are functional but not vectorized. At least some of these should be vectorized for at least some data types subsequently, but that's a more intensive change. Once that's in, we can update a few places to use these, e.g. Regex should end up using any of the overloads that are vectorized.
* Fix comments
These are functional but not vectorized. At least some of these should be vectorized for at least some data types subsequently, but that's a more intensive change. Once that's in, we can update a few places to use these, e.g. Regex should end up using any of the overloads that are vectorized.
Fixes #28795
#67942 tracks vectorizing these.