shader: decode and lower v_dot8_i32_i4 #44

Merged
lcg007xd-c merged 1 commit from upstream-pr/44 into main 2026-11-25 20:33:20 +00:00
lcg007xd-c commented 2026-11-25 20:24:50 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lcg007xd-c on 2026-11-25T20:24:50Z.


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

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:6613054127 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/44). Originally posted by [lcg007xd-c](https://github.com/lcg007xd-c) on 2026-11-25T20:24:50Z. --- ## 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)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!44
No description provided.