feat: [U3-C] full correctness matrix: padded shapes, over-width shift… - #29
Merged
Merged
Conversation
…s, boundary asserts
EdanStasiuk
approved these changes
Jul 21, 2026
EdanStasiuk
left a comment
Collaborator
There was a problem hiding this comment.
Lgtm, @angelo-yap want to review?
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: #9
Summary
Grows the differential harness from a per-op smoke test into the full
correctness matrix: every operation × width × shape, including the padded path
and the edge cases earlier updates deferred. Builds on the comparison/ashr
lowerings (#7), the SWAR sub/shift masks (U2-B), and the non-byte-multiple
padding path (U3-A), all of which are now on
main.Three areas of coverage were added, each following the existing test-suite
conventions (drop-in kernel files driven by
tools/diff_runner.py, no per-opharness logic):
Full padded matrix —
test/pad_diff.llgrows from a handful ofrepresentative shapes (12 kernels) to the complete non-byte-multiple matrix
(36 kernels): every lowered op (
and/or/xor/add/sub/shl/lshr/ashr/eq/ne/ult/slt)at each field width
i1/i2/i4on a shape whose total bit width isn't amultiple of 8, exercising the zero-pad → carrier → narrow path end-to-end.
The previously-absent comparisons and ashr are now part of the padded
matrix, and shapes include the ticket's named cases (
<5 x i1>,<12 x i1>,<3 x i4>).At/over-width shift amounts — the concrete home for the U2-B
amount-semantics decision (mask the amount to N, i.e.
amount & (N-1)).tools/diff_runner.pypreviously clamped every shift amount into[0, N-1], so the over-width case was silently clamped away and neverdifferentiated. Added an
_ovfkernel-name marker: kernels that self-maskthe amount in-IR (
and %b, N-1) are recognized by the harness and fed thefull unclamped amount range instead of being clamped, so counts ≥ N
actually flow through. Because the kernel masks before the reference shift,
the scalar reference stays defined even for raw out-of-range inputs, and the
candidate SWAR lowering must agree with it. New
test/shift_overwidth.llcovers
shl/lshr/ashr×i2/i4, byte-multiple and padded;diff/{shl,lshr, ashr}.llare documented as the in-range companion.Explicit boundary assertions — new
test/edge_values.llpins the exactexpected result bytes for the semantically interesting edge cases —
all-zero and all-ones fields, and the signed high-bit boundary for
slt/ashrsign handling — acrossi1/i2/i4. Unlike the differential kernels,this is a golden test: the module is lowered by the pass and its executed
output is checked directly against literals (
slt(-8,+7)→ff,ashr(-8,3)→ffsign-fill,add(15,15)→eewrap,sub(0,1)→ffborrow, …),independent of any reference interpreter.
Notes / findings
LLVM_DIR=/usr/lib/ llvm-22/cmake), so the suite must run with the-22tools —opt-16fails to load the plugin and can't parse the
splatconstant syntax used inthe kernels.
a negative control — a raw, non-self-masking
_ovfkernel mismatches thepoison scalar reference on the structured
0xFF/0x80fills, while theself-masking kernel passes. The over-width amounts are present
deterministically (via the structured fills), so coverage doesn't depend on
the RNG seed.
Tests
pad_diff.ll, 36 kernels / 4896 trials) green, includingcomparisons and ashr; re-verified across seeds 1 / 7 / 12345.
shift_overwidth.ll(12 kernels / 1632 trials) green across the same seeds.edge_values.llgolden assertions pass (lowered output matches all pinnedbytes).
shift_overwidth.ll,+
edge_values.ll), 0 XFAIL. Byte-multiple and padded matrices both green;no operation silently skipped (no
total % 8 != 0bypass, no trivial-passno-op lowering).