Simplify UTF-16 validation Vector128 codepath#121981
Merged
Merged
Conversation
Combine the SSE2 codepath with a more generic Vector128 algorithm. AdvSimd is handled slightly differently to avoid using Vector128 ExtractMostSignificantBits, because there is no such equivalent instruction on Arm so the performance would be very slow otherwise.
Contributor
Author
|
cc @dotnet/arm64-contrib @a74nh @SwapnilGaikwad @tannergooding @EgorBo |
This was referenced Nov 26, 2025
Open
tannergooding
approved these changes
Dec 2, 2025
Member
|
Improvements: dotnet/perf-autofiling-issues#67360 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-attempt at #121383.
Refactor the vectorized code path by combining the SSE2 "intrinsified" path with the original Vector128 algorithm. There are still some platform specific code (for AdvSimd), as it is difficult to fully rely on Vector128 APIs without sacrificing performance too much. The main issue is the lack of an instruction for
Vector128.ExtractMostSignificantBitson Arm, so it is significantly slower when trying to force it to use the same mask format as the SSE2 algorithm. I have looked into the possibility of usingIndexOfandCountetc, but they also useExtractMostSignificantBitsso it poses the same problem.This PR tries to encapsulate this difference in a few helper methods so they can share the same code path for the main algorithm.
Performance wise, there is not as much improvements, but hopefully the code will be easier to maintain.
Arm Neoverse-V2:
Intel Sapphire Rapids: