tests: cover the untested 16-bit integer ALU opcodes #1151
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1151
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1151/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Nawid3333 on GitHub · 2026-10-07 16:23 UTC · original
Nawid3333:tests/int16-alu-coverage→main· +147 −0 · 1 files · 4 commits · merged 2026-10-07 23:31 UTCWhat
25 16-bit integer opcodes decode and translate, but no file under
tests/names them (checked by name onmaind2413fc2; no open PR adds them either):V_CMP_{EQ,LE,GT,NE}_I16,V_CMP_{EQ,LE,GT,NE,GE}_U16V_SUB_NC_U16,V_ADD_NC_I16,V_ASHRREV_I16,V_MAX_U16,V_MIN_U16V_PK_MAD_I16,V_PK_MAD_U16,V_PK_MUL_LO_U16,V_PK_ADD_I16,V_PK_SUB_U16,V_PK_LSHLREV_B16,V_PK_LSHRREV_B16,V_PK_ASHRREV_I16,V_PK_MIN_I16,V_PK_MAX_U16,V_PK_MIN_U16This adds three GPU cases to
shader_recompiler_compute_tests, one commit per family. They run in the default list and together with--int16-alu-only. Test-only: no source change.What the cases check
VectorCompareI16U16Ops: the same low halves (0x8000vs0x7fff) through the signed and the unsigned compares, which must disagree, plus equal operands. The operands' high halves differ (0xabcd8000vs0x12348000), so the case also checks that only the low 16 bits are compared.Vop3Int16Ops: wraparound without clamp (0x0001 - 0x0002,0x7fff + 0x0001);V_ASHRREV_I16shifting src1 by src0's low four bits (0x0013shifts by 3); unsigned max/min on0x8000vs0x7fff; and the destination's high half preserved (as inFloatInlineConstantF16UsesNumericValue).Vop3pInt16Ops: every op on both halves with the default half selection: wraparound, per-half shift amounts, and min/max on0x8000vs0x0001so signed and unsigned ordering give different results.The expected values were worked out from the instruction semantics, not taken from Kyty's output. Two of them were cross-checked against LLVM's AMDGPU backend:
V_ASHRREV_I16shifts src1 by src0:cashr_revis(csra $src1, $src0)with the shift amount masked to the width (AMDGPUInstructions.td).GCNSubtarget::zeroesHigh16BitsOfDestreturnsgetGeneration() <= AMDGPUSubtarget::GFX9for these opcodes, with the comment "On gfx10, all 16-bit instructions preserve the high bits."Testing
Windows 11, clang-cl 19.1.5, Release, AMD RX 9070 XT, this branch (
055d55bc, onmaind2413fc2):shader_recompiler_compute_tests --int16-alu-only: all three cases pass.translate/Vector.cpp(V_CMP_GT_U16:UGreaterThan32→SGreaterThan32;V_MAX_U16:UMax32→SMax32;V_PK_MIN_U16:UMin32→SMin32; one at a time), the matching case fails at readback.shader_cfg,resource_tracking,resource_materialization,scalar_provenance,shader_vertex_metadata,lru_cache,ime_dialog,audio_out2_port,pad_hapticsandcontroller_settingspass.AI use (per the README's AI policy): Claude (Anthropic) found the untested opcodes, wrote the cases, derived the expected values, did the LLVM cross-check and ran the checks above on my machine. I reviewed the cases and the results before opening this PR.
🤖 Generated with Claude Code
V_CMP_{EQ,LE,GT,NE}_I16 and V_CMP_{EQ,LE,GT,NE,GE}_U16 decode and translate but no test exercised them. VectorCompareI16U16Ops compares low halves that differ in sign interpretation (0x8000 vs 0x7fff) with both the signed and the unsigned opcodes, and uses operands whose high halves differ to check that only the low 16 bits are compared. It runs in the default list and with --int16-compare-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>@coderabbitai[bot] on GitHub · 2026-10-07 18:10 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
6450eb4a-3cd9-447a-bdf0-94ae6139f066📥 Commits
Reviewing files that changed from the base of the PR and between
038d2257deand7b8d1cac2c.📒 Files selected for processing (1)
tests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
Adds compute tests for packed and scalar 16-bit integer operations and signed and unsigned comparisons. Registers the tests in the general test-case list. Adds
--int16-alu-onlyto run the three tests with a Vulkan harness.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Other
Merge Risk: ⚪ Minimal · up to
7b8d1This PR only adds tests for 16-bit integer opcodes and a command-line option to run them. It does not change production behavior, and no merge-blocking risk was found.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.