shader: decode and lower v_dot8_i32_i4 #44

Manually merged
github merged 1 commit from gh-pr/44/head into gh-pr/44/base 2026-11-26 03:42:27 +00:00
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 20:24 UTC · original
lcg007xd-c:shader/v-dot8-i32-i4 → main · +81 −0 · 4 files · 1 commits · merged 2026-11-25 20:33 UTC

What this fixes

VOP3P opcode 0x18, v_dot8_i32_i4, is missing from gfx10/opcodes.rs. 0x16, 0x17 and 0x19 are there, so any program using it fails at decode. AMD's RDNA2 ISA lists it, and so does LLVM's llvm-mc --disassemble -mcpu=gfx1030, which I used to cross-check the table.

The change (emit/dot.rs, next to v_dot8_u32_u4)

  • Opcode table: adds (0x018, "v_dot8_i32_i4").
  • Lowering: eight signed nibble products, each nibble shifted to the top of the dword and back arithmetically, summed into the accumulator with 32-bit wrapping.
  • Clamp: saturates the accumulator add through the existing sat_i32_add. The eight products alone stay in [−448, 512], so only that add can overflow.

Tests

  • emit::lower::tests::signed_nibble_dot_product_translates (runs on every host): the encoding decodes to v_dot8_i32_i4, and a program that stores the result translates both unclamped and clamped. The store keeps the instruction from being dropped as dead code. The test fails without the table entry, and fails with "an unhandled dot product" without the dot.rs arm.
  • valu_tests (Windows/GPU): adds two hand-computed cases next to the v_dot8_u32_u4 one. All nibbles −1 times all 7, plus 100, gives 44. All nibbles −8 times all −8 gives 512.

Run here (Linux, Rust 1.98.1):

  • cargo test -p victory-shader --lib --locked: 187 passed, 0 failed, 2 ignored.
  • cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.
  • The portable clippy run reports only the existing unused variable: out, which #39 fixes.

Not run here: the GPU cases, since I have no Windows machine.

The same fix is open upstream as Marvisak/VIctory#2768 (Windows CI green) and on the Belobug fork as #184.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:24 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/44) `lcg007xd-c:shader/v-dot8-i32-i4` → `main` · +81 −0 · 4 files · 1 commits · merged 2026-11-25 20:33 UTC ## What this fixes VOP3P opcode **0x18, `v_dot8_i32_i4`**, is missing from `gfx10/opcodes.rs`. 0x16, 0x17 and 0x19 are there, so any program using it fails at decode. AMD's RDNA2 ISA lists it, and so does LLVM's `llvm-mc --disassemble -mcpu=gfx1030`, which I used to cross-check the table. ## The change (`emit/dot.rs`, next to `v_dot8_u32_u4`) - **Opcode table:** adds `(0x018, "v_dot8_i32_i4")`. - **Lowering:** eight signed nibble products, each nibble shifted to the top of the dword and back arithmetically, summed into the accumulator with 32-bit wrapping. - **Clamp:** saturates the accumulator add through the existing `sat_i32_add`. The eight products alone stay in [−448, 512], so only that add can overflow. ## Tests - **`emit::lower::tests::signed_nibble_dot_product_translates`** (runs on every host): the encoding decodes to `v_dot8_i32_i4`, and a program that **stores** the result translates both unclamped and clamped. The store keeps the instruction from being dropped as dead code. The test fails without the table entry, and fails with "an unhandled dot product" without the `dot.rs` arm. - **`valu_tests`** (Windows/GPU): adds two hand-computed cases next to the `v_dot8_u32_u4` one. All nibbles −1 times all 7, plus 100, gives **44**. All nibbles −8 times all −8 gives **512**. **Run here** (Linux, Rust 1.98.1): - `cargo test -p victory-shader --lib --locked`: 187 passed, 0 failed, 2 ignored. - `cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`: clean. - The portable clippy run reports only the existing `unused variable: out`, which #39 fixes. **Not run here:** the GPU cases, since I have no Windows machine. The same fix is open upstream as Marvisak/VIctory#2768 (Windows CI green) and on the Belobug fork as #184. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
VOP3P 0x18 was missing from the opcode table (0x16, 0x17 and 0x19 are
there; AMD's RDNA2 ISA and LLVM's gfx1030 disassembler list it), so a
program using it failed to decode. It lowers beside v_dot8_u32_u4: eight
sign-extended nibble products plus the accumulator; clamp saturates the
accumulator add (the products alone stay in [-448, 512]).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:27 +00:00
github manually merged commit 2b485d6710 into gh-pr/44/base 2026-11-26 03:42:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.