Repository navigation
Fix __memcpy_chunks skipping bytes in partial loads - #15
Open
codethinki wants to merge 1 commit into
Open
codethinki wants to merge 1 commit into
codethinki wants to merge 1 commit into
Conversation
The second copy of a branch was only _Chunk bytes wide, so at the top of a branch's range the bytes in between were never copied. 4 remaining 1-byte elements copied bytes 0, 1 and 3, 4 remaining 2-byte elements copied bytes 0-3 and 6-7. Every branch now copies the same width from the front and the back. tests/loads.cpp: Add partial_load_every_size.
Author
|
Did not write the fixes, claude opus 5.5 did. However I code reviewed and approve as far as I can understand it. If you have any questions or comments I'll reply / fix it as soon as I can. |
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.
partial_loadloses an element when the remaining bytes are at the top of a__memcpy_chunksbranch: the second copy is only_Chunkbytes wide, so the bytes in between are never copied.With
vec<char, 64>this hits every tail of 4, 20, 36 and 52 elements. The same code ships with libstdc++ in GCC 16.2.Every branch now copies the same width from the front and the back, which covers
(k, 2k]bytes for any chunk size.tests/loads.cpp:partial_load_every_sizeloads everynfrom 0 toV::sizewith an unknownn(a knownntakes the singlememcpypath). It fails without the fix and passes with it for signed char, short, int, long long, float and double at widths 4, 8, 16, 20, 32, 36 and 64 on x86-64 and x86-64-v3 with GCC 16.2.1.