Fix packed uint1b logical array reductions - #3531
Open
wei-core wants to merge 1 commit into
Open
Conversation
Use the correct logical identities when reducing packed uint1b arrays, require every full byte for logical AND, and mask padding bits in partial trailing bytes. Correct the logical OR specialization signature and add exhaustive coverage across bit and storage boundaries. Signed-off-by: WikAlie <194917782+wei-core@users.noreply.github.com>
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.
Summary
uint1b_tlogical OR reduction specialization to acceptlogical_orBackground
The logical OR specialization currently cannot be called through
ReduceArraybecause its operator takeslogical_and. Even when called directly through the specialization, itstrueidentity makes an all-zero array reduce to true.The logical AND specialization checks whether each storage byte is nonzero rather than whether every valid bit is set. For example,
0x7fincorrectly reduces to true. Partial trailing bytes also need a mask so padding bits do not participate in either reduction.This change keeps the packed-byte path: full bytes are reduced directly, while only the valid low bits of a partial trailing byte are considered.
Contribution roles
I led the contribution direction and acceptance criteria, reviewed and approved
the final design, and reviewed every changed line. I understand the change and
own the final design decision and the submission. AI assistance was used for
repository research, root-cause analysis, implementation preparation, and
automated validation execution.
Testing
[1,1,1,1,1,1,1,0]returned 1, and OR of an all-zero array returned 1N = 1, 7, 8, 9, 15, 16, 32, including padding-bit isolationgit diff --checkFixes #3510