Vectorize mismatch
for clang-cl for odd element sizes
#5591
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.
Towards #5479
Unlike other comparing algorithms,
mismatch
vectorization can be expanded towards arbitrary element size easily, without even adding separately-compiled code. This is currently possible for clang-cl only, and it requires defaultedoperator==
, and trivially-comparable types, and unique object representation.The mismatch result can be divided by element size in the header, thus truncating any offset into the middle, giving the element index. The division is likely to be optimized to large multiplication by the compiler.
Rather than using just
__std_mismatch_1
, attempt to use as large element mismatch as possible, for the following reasons:_2
/_4
/_8
versions in the first place.lexicographical_compare
vectorization cannot be expanded this way, as it requires a different flavor of trivial comparability.Benchmark results
bm<color, op::mismatch, c1, c2>/8/3
bm<color, op::mismatch, c1, c2>/24/22
bm<color, op::mismatch, c1, c2>/105/-1
bm<color, op::mismatch, c1, c2>/4021/3056