tests: cover the untested 16-bit integer ALU opcodes #1151

Manually merged
github merged 4 commits from gh-pr/1151/head into gh-pr/1151/base 2026-11-26 09:45:11 +00:00
Owner

@⁠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 UTC

What

25 16-bit integer opcodes decode and translate, but no file under tests/ names them (checked by name on main d2413fc2; no open PR adds them either):

  • VOPC: V_CMP_{EQ,LE,GT,NE}_I16, V_CMP_{EQ,LE,GT,NE,GE}_U16
  • VOP3: V_SUB_NC_U16, V_ADD_NC_I16, V_ASHRREV_I16, V_MAX_U16, V_MIN_U16
  • VOP3P: V_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_U16

This 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 (0x8000 vs 0x7fff) through the signed and the unsigned compares, which must disagree, plus equal operands. The operands' high halves differ (0xabcd8000 vs 0x12348000), so the case also checks that only the low 16 bits are compared.
  • Vop3Int16Ops: wraparound without clamp (0x0001 - 0x0002, 0x7fff + 0x0001); V_ASHRREV_I16 shifting src1 by src0's low four bits (0x0013 shifts by 3); unsigned max/min on 0x8000 vs 0x7fff; and the destination's high half preserved (as in FloatInlineConstantF16UsesNumericValue).
  • Vop3pInt16Ops: every op on both halves with the default half selection: wraparound, per-half shift amounts, and min/max on 0x8000 vs 0x0001 so 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_I16 shifts src1 by src0: cashr_rev is (csra $src1, $src0) with the shift amount masked to the width (AMDGPUInstructions.td).
  • The destination's high half is kept: GCNSubtarget::zeroesHigh16BitsOfDest returns getGeneration() <= AMDGPUSubtarget::GFX9 for 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, on main d2413fc2):

  • shader_recompiler_compute_tests --int16-alu-only: all three cases pass.
  • The cases can fail: with one opcode translated as signed in 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_haptics and controller_settings pass.
  • Builds on Windows, Linux and macOS (fork CI: https://github.com/Nawid3333/KytyPS5/actions/runs/37648075939).

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

**@⁠Nawid3333** on GitHub · 2026-10-07 16:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1151) `Nawid3333:tests/int16-alu-coverage` → `main` · +147 −0 · 1 files · 4 commits · merged 2026-10-07 23:31 UTC ## What 25 16-bit integer opcodes decode and translate, but no file under `tests/` names them (checked by name on `main` d2413fc2; no open PR adds them either): - VOPC: `V_CMP_{EQ,LE,GT,NE}_I16`, `V_CMP_{EQ,LE,GT,NE,GE}_U16` - VOP3: `V_SUB_NC_U16`, `V_ADD_NC_I16`, `V_ASHRREV_I16`, `V_MAX_U16`, `V_MIN_U16` - VOP3P: `V_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_U16` This 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 (`0x8000` vs `0x7fff`) through the signed and the unsigned compares, which must disagree, plus equal operands. The operands' high halves differ (`0xabcd8000` vs `0x12348000`), so the case also checks that only the low 16 bits are compared. - `Vop3Int16Ops`: wraparound without clamp (`0x0001 - 0x0002`, `0x7fff + 0x0001`); `V_ASHRREV_I16` shifting src1 by src0's low four bits (`0x0013` shifts by 3); unsigned max/min on `0x8000` vs `0x7fff`; and the destination's high half preserved (as in `FloatInlineConstantF16UsesNumericValue`). - `Vop3pInt16Ops`: every op on both halves with the default half selection: wraparound, per-half shift amounts, and min/max on `0x8000` vs `0x0001` so 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_I16` shifts src1 by src0: `cashr_rev` is `(csra $src1, $src0)` with the shift amount masked to the width (`AMDGPUInstructions.td`). - The destination's high half is kept: `GCNSubtarget::zeroesHigh16BitsOfDest` returns `getGeneration() <= AMDGPUSubtarget::GFX9` for 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, on `main` d2413fc2): - `shader_recompiler_compute_tests --int16-alu-only`: all three cases pass. - The cases can fail: with one opcode translated as signed in `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_haptics` and `controller_settings` pass. - Builds on Windows, Linux and macOS (fork CI: https://github.com/Nawid3333/KytyPS5/actions/runs/37648075939). **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](https://claude.com/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]>
V_SUB_NC_U16, V_ADD_NC_I16, V_ASHRREV_I16, V_MAX_U16 and V_MIN_U16 decode and
translate but no test exercised them. Vop3Int16Ops checks wraparound without
clamp, the shift amount taken from the low four bits of src0, unsigned
ordering for max/min on 0x8000 vs 0x7fff, that the high halves of the sources
are ignored and that the high half of the destination is preserved. It runs in
the default list and with --int16-alu-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
V_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
and V_PK_MIN_U16 decode and translate but no test exercised them. Vop3pInt16Ops
runs each on both halves with the default half selection: wraparound without
clamp, shift amounts from the low four bits of each src0 half, and min/max on
0x8000 vs 0x0001 so signed and unsigned ordering give different results. It
runs in the default list and with --int16-alu-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:45:09 +00:00
github manually merged commit 7b8d1cac2c into gh-pr/1151/base 2026-11-26 09:45:11 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-07 18:10 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6450eb4a-3cd9-447a-bdf0-94ae6139f066
📥 Commits

Reviewing files that changed from the base of the PR and between 038d2257de and 7b8d1cac2c.

📒 Files selected for processing (1)
  • tests/ShaderRecompilerComputeTests.cpp

Included 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-only to run the three tests with a Vulkan harness.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to 7b8d1

This 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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding tests for previously untested 16-bit integer ALU opcodes.
Description check ✅ Passed The description is directly related to the changeset and provides detailed coverage, testing, and validation information for the new 16-bit integer ALU tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-07 18:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1151#issuecomment-6043948729) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1151?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `6450eb4a-3cd9-447a-bdf0-94ae6139f066` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 038d2257de858517dcca8efae2f1b15d568e1d64 and 7b8d1cac2c2668032e85a821a8b332b356804f63. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## 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-only` to run the three tests with a Vulkan harness. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"7b8d1cac2c2668032e85a821a8b332b356804f63" --> **Change:** Other <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `7b8d1` <!-- final_review_risk_coverage:{"sourceCommitId":"7b8d1cac2c2668032e85a821a8b332b356804f63","coveredCommitId":"7b8d1cac2c2668032e85a821a8b332b356804f63","kind":"reviewed"} --> This 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. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely describes the main change: adding tests for previously untested 16-bit integer ALU opcodes. | | Description check | ✅ Passed | The description is directly related to the changeset and provides detailed coverage, testing, and validation information for the new 16-bit integer ALU tests. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0… | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1151)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.