Conversation
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #70.
Adds
sz_rfind_2byte_serial_,sz_rfind_3byte_serial_, andsz_rfind_4byte_serial_, mirroring the forward SWAR kernels, and wires them intosz_rfind_serialin place of the TODO slots. Previously every 2..256-byte needle in reverse went through Horspool.Each kernel walks backwards over 8 candidate offsets
[last - 7, last]per iteration. It reuses the samesz_u64_each_{2,3,4}byte_equal_masks and lane shifts as the forward versions, and picks the highest matching lane with63 - clzinstead ofctz. The big-endian fallback and the!SZ_USE_MISALIGNED_LOADSalignment tail follow the same structure assz_rfind_byte_serial.Validation (x86_64, GCC)
cmake -D STRINGZILLA_BUILD_TEST=1 -D STRINGZILLA_USE_SANITIZERS=0 -D CMAKE_BUILD_TYPE=Release -B build_release && cmake --build build_release --target stringzilla_test_cpp20→build_release/stringzilla_test_cpp20: All tests passed.memcmpreverse search: 400k random cases covering haystack lengths 0..299, needle lengths 2..4, start offsets 0..15 (misaligned), small alphabets plus high-bit bytes. Checked bothsz_rfind_serialand the dispatchedsz_rfind, built with-fsanitize=address,undefinedandSZ_USE_MISALIGNED_LOADS=0/1. 0 mismatches, no ASan reports.sz_rfind_serialon a 1 MiB random haystack with no match,-O2:Not tested: big-endian targets (that path is the plain byte loop) and non-x86 hardware.