Repository navigation
Translator: v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32, v_msad_u8 - #544
Merged
Merged
Conversation
All five raised Unsupported. They add the sum of absolute differences of the sources' bytes / halves / words to S2 (unsigned, wrapping at 32 bits), as in the RDNA ISA pseudocode; v_sad_hi_u8 shifts the byte sum left by 16 and v_msad_u8 skips the bytes where S1's byte is 0. clamp is rejected, not guessed. tests/semantic/test_alu_sad.py checks all five against a plain-Python reference. test_translate.py and test_f16_op_sel.py used v_sad_u8 as their example of an unsupported instruction; they now use v_mqsad_u32_u8.
Contributor
|
Tested 7a86a2e on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass.
No GPU shader in the suite uses the v_sad/v_msad ops yet, so the GPU run is a regression check only. Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 19.50, Python 3.13. |
ItsNotRexed
pushed a commit
that referenced
this pull request
Nov 22, 2026
…ROC-20) #544, #549 and #577 merged without a row in the contract table, which AGENTS.md asks for. One row per group, each with the semantics (checked against the RDNA2 ISA pseudocode), what is not handled (clamp on the SAD and lerp ops) and how it was confirmed (the CPU tests added by the PR); none is GPU-checked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 22, 2026
This was referenced Nov 22, 2026
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.
tools/rdna2spirv.pyraisesUnsupportedon the sum-of-absolute-differences ops:v_sad_u8,v_sad_hi_u8,v_sad_u16,v_sad_u32andv_msad_u8. They aren't in the translated corpus, so this is future-proofing. Claimed in #374.Change
tools/rdna2spirv.pyfollows the RDNA ISA pseudocode. Everything is unsigned and wraps at 32 bits:v_sad_u8: S2 + Σ over the 4 bytes of |S0.b − S1.b|v_sad_hi_u8: S2 + (that byte sum << 16)v_sad_u16: S2 + Σ over the 2 halves of |S0.h − S1.h|v_sad_u32: S2 + |S0 − S1|v_msad_u8: likev_sad_u8, but a byte is skipped where S1's byte is 0 (masked SAD)UMax − UMinof the extracted fields.clampraisesUnsupportedinstead of being guessed. The pseudocode doesn't define what clamp does to these ops.tests/semantic/test_alu_sad.py(new, stdlibunittest) checks against a plain-Python reference:v_msad_u8clamprejectedexpas two 16-bit halves ORed into0x40000000, so no export channel can be a NaN or denormal pattern (the problem found in review on tests/semantic: export test_alu_shift_b64 results in 16-bit halves (fixes CI on Python < 3.14) #454).tests/test_translate.pyandtests/test_f16_op_sel.pyusedv_sad_u8as their example of an unsupported instruction. They now usev_mqsad_u32_u8, which stays unsupported. The destination doesn't overlap the sources, because LLVM marks that op's vdst early-clobber.Tested
python -I -m unittest discover -s tests/semantic: all pass. Without the translator change, the new file has 446 errors (Unsupported). It also passes with the interpreter forced to quiet signalling NaNs.tests/test_f16_op_sel.py: 34/34 pass through a localpyteststand-in, because I can't install pytest here. That includes the changedtest_other_unsupported_instructions_are_still_rejected. I couldn't runtests/test_translate.py, because it needsllvm-mc; CI runs it.python -m compileall -q tools testspasses. Not run on a GPU, and no game files used.AI-assisted (Claude Code): it wrote the change and the tests, and ran the checks listed above.