feat: 16-bit integer VALU (VOP3 16-bit ops and packed VOP3P) in the RDNA 2 interpreter and HLSL — 1,178/1,490 #232

Merged
KainanP merged 1 commit from upstream-pr/232 into main 2026-11-26 00:15:07 +00:00
KainanP commented 2026-11-25 20:05:31 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-25T20:05:31Z.


Change

The reference interpreter and the HLSL recompiler now run the 16-bit integer VALU: 40 encodings that until now raised Untranslated / Untranslatable.

Group Encodings Semantics
VOP3 16-bit ops v_add/sub_nc_{u16,i16}, v_mul_lo_u16, v_lshlrev_b16, v_lshrrev_b16, v_ashrrev_i16, v_max/min_{u16,i16}, v_mad_{u16,i16}, v_min3/max3/med3_{u16,i16} (20) op_sel[0-2] read S[31:16], op_sel[3] writes D[31:16], the other half of D is kept; results wrap to 16 bits; clamp saturates add/sub/mad to [0, 0xFFFF] or [-32768, 32767]
16 × 16 + 32 v_mad_u32_u16, v_mad_i32_i16 op_sel[0-1] pick the source halves, clamp saturates the 32-bit sum; op_sel[2]/op_sel[3] (32-bit S2 and D) refused
Packs / signed 32-bit v_cvt_pk_u16_u32, v_cvt_pk_i16_i32, v_add_nc_i32, v_sub_nc_i32 D = {sat16(S1), sat16(S0)}; 32-bit wrap, clamp saturates signed
Packed VOP3P v_pk_{add,sub,mad}_{u16,i16}, v_pk_mul_lo_u16, v_pk_{max,min}_{u16,i16}, v_pk_lshlrev_b16, v_pk_lshrrev_b16, v_pk_ashrrev_i16 (14) half 0 from op_sel, half 1 from op_sel_hi; clamp saturates add/sub/mad per half, no-op on max/min

A constant source is its 32-bit value split like a register: inline integers sign-extended (-16 = 0xFFF0/0xFFFF), inline floats their float32 bits (1.0 = 0x0000/0x3F80), a literal its whole dword (LLVM, below).

Refused by name (rule 3), in both the interpreter and HLSL: VOP3 abs/neg/omod and VOP3P neg_lo/neg_hi on these integer ops; clamp where it is not implemented (v_mul_lo_u16 and v_pk_mul_lo_u16, the 16-bit shifts and VOP3 min/max, min3/max3/med3, the packs, the packed shifts); op_sel[2]/op_sel[3] on v_mad_u32_u16/v_mad_i32_i16; op_sel on the packs and on v_add/sub_nc_i32. The select bits of the third source of a two-source op are ignored (no third operand is read; LLVM itself writes op_sel_hi[2] = 0 there).

New files: emu/rdna2_exec_int16.py (interpreter, refusal rules shared with HLSL) and emu/rdna2_hlsl_int16.py (integer-only HLSL, no 64-bit types, so it runs on Intel UHD too).

Driver finding (NVIDIA): the first HLSL version wrote the signed 16-bit saturating add/sub as clamp(Sext16(a) ± Sext16(b), -32768, 32767), masked to 16 bits when stored in its half. On the RTX 4060 Laptop GPU the sign-extended high half (0xFFFF) reached the destination in 10 and 9 of 32 lanes of v_add_nc_i16 clamp / v_sub_nc_i16 clamp (e.g. 0xFFFFAAAB where the interpreter gives 0x0001AAAB); WARP and Intel UHD were right. It is now computed from the sign bits in uint (AddSatI16), and the parity test covers it. (v_mad_i16 clamp and v_cvt_pk_i16_i32, which use the same clamp, were right.)

Coverage, recounted on the tree merged with main e921268: interpreter 1,208 → 1,248 of 1,490 encodings (README 81% → 84%, from rdna2_exec.coverage()); test count 1400+ → 1500+ (1,517 collected). Same change in the 9 READMEs.

The int16 helpers (AddSatI16, AddSatI32…) are now also part of the graphics HLSL (rdna2_hlsl_graphics.py), so a vertex or pixel shader using them compiles. A vertex-shader test runs the helper-backed ops on the GPU and compares them with the interpreter. Same change in the 9 READMEs.

Verification

Branch rebased on main e921268 (head 40aae0f). Tests were run on the same tree rebased on 9a06443; e921268 only adds launcher/docs changes.

python -m pytest                          → 1499 passed, 17 skipped (RTX 4060 Laptop, default adapter)
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

HLSL path on the other two adapters (the two new files plus test_rdna2_exec_dot.py, test_rdna2_vop3p.py, test_rdna2_alu_parity.py, test_rdna2_exec.py, test_rdna2_exec_vop3_more.py, test_rdna2_hlsl_wave64.py, test_rdna2_exec_cmp16.py, test_rdna2_hlsl.py, including the new vertex-shader test):

WARP (ANYXBOXX_GPU=warp)                         → 253 passed
Intel UHD Graphics (ANYXBOXX_GPU=Intel, 16-lane) → 253 passed

Without the rdna2_hlsl_graphics.py change, dxc rejects the vertex shader of the new graphics test (AddSatI16 undefined); with it, the shader compiles. The skips of the full run are the usual ones on this machine (Rust crates and TomBox DLLs not built, no Vulkan SDK for spirv-as).

Oracle and test data

  • HLSL checked against the reference interpreter, byte for byte, on RTX, WARP and Intel UHD:
    • test_int16_ops_match_interpreter_on_gpu (wave32) and ..._in_wave64: 174 instructions, every encoding of the family with its op_sel / op_sel_hi / clamp variants plus inline integer, inline float and literal sources, run under a partial EXEC (0x0F0FF0F3; 0xF00F0FF0 for the upper 32 lanes) on per-lane sources whose halves are boundary values (0x0000 0x0001 0x0002 0x000F 0x0011 0x7FFE 0x7FFF 0x8000 0x8001 0xFFFE 0xFFFF 0x1234 0xAAAA 0x4000 0xC000, one lane in eight random), each destination preset to a per-lane old value. test_parity_program_results_vary_by_lane guards that results vary per lane and that inactive lanes keep their old value.
  • Interpreter expectations are worked out by hand (tests/test_rdna2_exec_int16.py, arithmetic in the comments): 95 tests covering wrap and saturation at both ends of each type, shift counts masked to 4 bits, high-half selects and the destination half, the 32-bit forms, constants, inactive lanes, and every refused form (with the HLSL refusal). None of the expected values is a hardware measurement: they come from the ISA pseudocode and the LLVM cross-checks named in the comments.
  • All test data is built in the tests; no external data.
  • Failure case: on main both new test files fail at collection (emu.rdna2_exec_int16 does not exist) and each of the 40 encodings raises instruction non traduite. test_rdna2_exec_dot.py now uses v_pk_add_f16 as its example of a still-refused packed op.

Sources (labelled per docs/research/rdna2-sources.md; printed page numbers of the archived PDF, SHA-256 22aec03f…4795):

  • AMD, "RDNA 2" ISA, November 2020: §12.10 VOP3P opcodes 0-13 (p. 162-163) and §12.12 VOP3 opcodes 771-788, 832, 850-857, 862, 874-875, 883, 885, 886, 895 (p. 178-187): pseudocode, "Supports saturation" on the 16-bit add/sub/mad and v_add/sub_nc_i32, and for V_MAD_U16/V_MAD_I16 "If op_sel[3] is 1: Result is written to 16 MSBs of destination VGPR and lo 16 bits are preserved". §13.3 tables 82 and 86 (p. 258, 263): VOP3 OPSEL "Operand select for 16-bit data. 0 = select low half, 1 = select high half", [14] = dest; VOP3P OPSEL / OPSEL_HI. §6.2.5 table 21 (p. 44): opcodes usable with OPSEL. §6.5 (p. 48): integer clamp "clamps the result to the largest and smallest representable value", so a max or min, whose result is one of its in-range inputs, is unchanged.
  • LLVM 20.1.8 (cross-check): lib/Target/AMDGPU/GCNSubtarget.cpp zeroesHigh16BitsOfDest: "On gfx10, all 16-bit instructions preserve the high bits" (the kept half of D). test/CodeGen/AMDGPU/{uaddsat,usubsat,saddsat,ssubsat}.ll select the saturating i16, v2i16 and i32 add/sub to v_add/sub_nc_{u16,i16}, v_pk_add/sub_{u16,i16} and v_add/sub_nc_i32 with clamp on GFX10. ssubsat uses v_sub_nc_i16 … clamp, so the saturation is signed, although the PDF says "unsigned 16-bit integer domain". lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp getInlineEncodingV216: for (packed) 16-bit instructions "integer encodings (-16 .. 64) are always produced as sign-extended 32-bit values", float encodings "for UI16 instructions: corresponding single-precision float value". test/CodeGen/AMDGPU/add.v2i16.ll (GFX10) encodes <123, 456> as the literal 0x1c8007b and <0, 16256> as 1.0.
  • Mesa (MIT, cross-check): nir_opcodes.py pack_uint_2x16 / pack_sint_2x16 "Convert two (un)signed integers into a packed (un)signed short (clamp is applied)", which ACO (aco_select_nir_alu.cpp) emits as v_cvt_pk_u16_u32 / v_cvt_pk_i16_i32. No code copied.

Assumptions left open (measurement request: akimfomin/PortBridge#84, sections A, B and E)

  1. v_cvt_pk_u16_u32 / v_cvt_pk_i16_i32 saturate (Mesa/ACO), e.g. v_cvt_pk_u16_u32(0x10000, 0x1234) = 0x1234FFFF.
  2. A 32-bit literal read through op_sel on a VOP3 16-bit op gives its high half, as LLVM's add.v2i16.ll shows for the packed form.
  3. Clamp on the 16-bit add/sub/mad, on v_add/sub_nc_i32 and v_mad_u32_u16/v_mad_i32_i16, and clamp as a no-op on v_pk_max/min, follow from §6.5 and LLVM rather than from a measurement.
  4. Refused until measured: clamp on v_mul_lo_u16 / v_pk_mul_lo_u16 (the PDF says V_MUL_LO_U16 "Supports saturation", but whether that saturates the full product is not stated), the 16-bit shifts, VOP3 min/max/min3/max3/med3, the packs and the packed shifts; op_sel[2]/op_sel[3] on v_mad_u32_u16/v_mad_i32_i16. v_sad_u16 is left out of this PR.

Checklist

  • The PR covers a single reviewable behaviour. (One instruction family: the 16-bit integer VALU, VOP3 and packed.)
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Unmeasured forms raise Untranslated / Untranslatable naming the instruction and the modifier.)
  • README: the same change in all 9 languages (test_readme_sync.py checks it).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

Made with AI assistance: Claude Code with Claude Opus 5.5, for KainanP.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6612722333 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/232). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T20:05:31Z. --- ## Change The reference interpreter and the HLSL recompiler now run the 16-bit integer VALU: 40 encodings that until now raised `Untranslated` / `Untranslatable`. | Group | Encodings | Semantics | | --- | --- | --- | | VOP3 16-bit ops | `v_add/sub_nc_{u16,i16}`, `v_mul_lo_u16`, `v_lshlrev_b16`, `v_lshrrev_b16`, `v_ashrrev_i16`, `v_max/min_{u16,i16}`, `v_mad_{u16,i16}`, `v_min3/max3/med3_{u16,i16}` (20) | `op_sel[0-2]` read `S[31:16]`, `op_sel[3]` writes `D[31:16]`, the other half of D is kept; results wrap to 16 bits; `clamp` saturates add/sub/mad to [0, 0xFFFF] or [-32768, 32767] | | 16 × 16 + 32 | `v_mad_u32_u16`, `v_mad_i32_i16` | `op_sel[0-1]` pick the source halves, `clamp` saturates the 32-bit sum; `op_sel[2]`/`op_sel[3]` (32-bit S2 and D) refused | | Packs / signed 32-bit | `v_cvt_pk_u16_u32`, `v_cvt_pk_i16_i32`, `v_add_nc_i32`, `v_sub_nc_i32` | `D = {sat16(S1), sat16(S0)}`; 32-bit wrap, `clamp` saturates signed | | Packed VOP3P | `v_pk_{add,sub,mad}_{u16,i16}`, `v_pk_mul_lo_u16`, `v_pk_{max,min}_{u16,i16}`, `v_pk_lshlrev_b16`, `v_pk_lshrrev_b16`, `v_pk_ashrrev_i16` (14) | half 0 from `op_sel`, half 1 from `op_sel_hi`; `clamp` saturates add/sub/mad per half, no-op on max/min | A constant source is its 32-bit value split like a register: inline integers sign-extended (`-16` = `0xFFF0`/`0xFFFF`), inline floats their float32 bits (`1.0` = `0x0000`/`0x3F80`), a literal its whole dword (LLVM, below). Refused by name (rule 3), in both the interpreter and HLSL: VOP3 `abs`/`neg`/`omod` and VOP3P `neg_lo`/`neg_hi` on these integer ops; `clamp` where it is not implemented (`v_mul_lo_u16` and `v_pk_mul_lo_u16`, the 16-bit shifts and VOP3 min/max, min3/max3/med3, the packs, the packed shifts); `op_sel[2]`/`op_sel[3]` on `v_mad_u32_u16`/`v_mad_i32_i16`; `op_sel` on the packs and on `v_add/sub_nc_i32`. The select bits of the third source of a two-source op are ignored (no third operand is read; LLVM itself writes `op_sel_hi[2] = 0` there). New files: `emu/rdna2_exec_int16.py` (interpreter, refusal rules shared with HLSL) and `emu/rdna2_hlsl_int16.py` (integer-only HLSL, no 64-bit types, so it runs on Intel UHD too). **Driver finding (NVIDIA):** the first HLSL version wrote the signed 16-bit saturating add/sub as `clamp(Sext16(a) ± Sext16(b), -32768, 32767)`, masked to 16 bits when stored in its half. On the RTX 4060 Laptop GPU the sign-extended high half (`0xFFFF`) reached the destination in 10 and 9 of 32 lanes of `v_add_nc_i16 clamp` / `v_sub_nc_i16 clamp` (e.g. `0xFFFFAAAB` where the interpreter gives `0x0001AAAB`); WARP and Intel UHD were right. It is now computed from the sign bits in `uint` (`AddSatI16`), and the parity test covers it. (`v_mad_i16 clamp` and `v_cvt_pk_i16_i32`, which use the same clamp, were right.) Coverage, recounted on the tree merged with main `e921268`: interpreter **1,208 → 1,248 of 1,490** encodings (README 81% → 84%, from `rdna2_exec.coverage()`); test count 1400+ → 1500+ (1,517 collected). Same change in the 9 READMEs. The int16 helpers (`AddSatI16`, `AddSatI32`…) are now also part of the graphics HLSL (`rdna2_hlsl_graphics.py`), so a vertex or pixel shader using them compiles. A vertex-shader test runs the helper-backed ops on the GPU and compares them with the interpreter. Same change in the 9 READMEs. ## Verification Branch rebased on main `e921268` (head `40aae0f`). Tests were run on the same tree rebased on `9a06443`; `e921268` only adds launcher/docs changes. ``` python -m pytest → 1499 passed, 17 skipped (RTX 4060 Laptop, default adapter) python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` HLSL path on the other two adapters (the two new files plus `test_rdna2_exec_dot.py`, `test_rdna2_vop3p.py`, `test_rdna2_alu_parity.py`, `test_rdna2_exec.py`, `test_rdna2_exec_vop3_more.py`, `test_rdna2_hlsl_wave64.py`, `test_rdna2_exec_cmp16.py`, `test_rdna2_hlsl.py`, including the new vertex-shader test): ``` WARP (ANYXBOXX_GPU=warp) → 253 passed Intel UHD Graphics (ANYXBOXX_GPU=Intel, 16-lane) → 253 passed ``` Without the `rdna2_hlsl_graphics.py` change, dxc rejects the vertex shader of the new graphics test (`AddSatI16` undefined); with it, the shader compiles. The skips of the full run are the usual ones on this machine (Rust crates and TomBox DLLs not built, no Vulkan SDK for `spirv-as`). ## Oracle and test data - HLSL checked against the reference interpreter, byte for byte, on RTX, WARP and Intel UHD: - `test_int16_ops_match_interpreter_on_gpu` (wave32) and `..._in_wave64`: 174 instructions, every encoding of the family with its `op_sel` / `op_sel_hi` / `clamp` variants plus inline integer, inline float and literal sources, run under a partial EXEC (`0x0F0FF0F3`; `0xF00F0FF0` for the upper 32 lanes) on per-lane sources whose halves are boundary values (`0x0000 0x0001 0x0002 0x000F 0x0011 0x7FFE 0x7FFF 0x8000 0x8001 0xFFFE 0xFFFF 0x1234 0xAAAA 0x4000 0xC000`, one lane in eight random), each destination preset to a per-lane old value. `test_parity_program_results_vary_by_lane` guards that results vary per lane and that inactive lanes keep their old value. - Interpreter expectations are worked out by hand (`tests/test_rdna2_exec_int16.py`, arithmetic in the comments): 95 tests covering wrap and saturation at both ends of each type, shift counts masked to 4 bits, high-half selects and the destination half, the 32-bit forms, constants, inactive lanes, and every refused form (with the HLSL refusal). None of the expected values is a hardware measurement: they come from the ISA pseudocode and the LLVM cross-checks named in the comments. - All test data is built in the tests; no external data. - Failure case: on main both new test files fail at collection (`emu.rdna2_exec_int16` does not exist) and each of the 40 encodings raises `instruction non traduite`. `test_rdna2_exec_dot.py` now uses `v_pk_add_f16` as its example of a still-refused packed op. Sources (labelled per `docs/research/rdna2-sources.md`; printed page numbers of the archived PDF, SHA-256 `22aec03f…4795`): - AMD, "RDNA 2" ISA, November 2020: §12.10 VOP3P opcodes 0-13 (p. 162-163) and §12.12 VOP3 opcodes 771-788, 832, 850-857, 862, 874-875, 883, 885, 886, 895 (p. 178-187): pseudocode, "Supports saturation" on the 16-bit add/sub/mad and `v_add/sub_nc_i32`, and for `V_MAD_U16`/`V_MAD_I16` "If op_sel[3] is 1: Result is written to 16 MSBs of destination VGPR and lo 16 bits are preserved". §13.3 tables 82 and 86 (p. 258, 263): VOP3 OPSEL "Operand select for 16-bit data. 0 = select low half, 1 = select high half", `[14]` = dest; VOP3P OPSEL / OPSEL_HI. §6.2.5 table 21 (p. 44): opcodes usable with OPSEL. §6.5 (p. 48): integer clamp "clamps the result to the largest and smallest representable value", so a max or min, whose result is one of its in-range inputs, is unchanged. - LLVM 20.1.8 (cross-check): `lib/Target/AMDGPU/GCNSubtarget.cpp` `zeroesHigh16BitsOfDest`: "On gfx10, all 16-bit instructions preserve the high bits" (the kept half of D). `test/CodeGen/AMDGPU/{uaddsat,usubsat,saddsat,ssubsat}.ll` select the saturating i16, v2i16 and i32 add/sub to `v_add/sub_nc_{u16,i16}`, `v_pk_add/sub_{u16,i16}` and `v_add/sub_nc_i32` with `clamp` on GFX10. `ssubsat` uses `v_sub_nc_i16 … clamp`, so the saturation is signed, although the PDF says "unsigned 16-bit integer domain". `lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp` `getInlineEncodingV216`: for (packed) 16-bit instructions "integer encodings (-16 .. 64) are always produced as sign-extended 32-bit values", float encodings "for UI16 instructions: corresponding single-precision float value". `test/CodeGen/AMDGPU/add.v2i16.ll` (GFX10) encodes `<123, 456>` as the literal `0x1c8007b` and `<0, 16256>` as `1.0`. - Mesa (MIT, cross-check): `nir_opcodes.py` `pack_uint_2x16` / `pack_sint_2x16` "Convert two (un)signed integers into a packed (un)signed short (clamp is applied)", which ACO (`aco_select_nir_alu.cpp`) emits as `v_cvt_pk_u16_u32` / `v_cvt_pk_i16_i32`. No code copied. ### Assumptions left open (measurement request: akimfomin/PortBridge#84, sections A, B and E) 1. `v_cvt_pk_u16_u32` / `v_cvt_pk_i16_i32` saturate (Mesa/ACO), e.g. `v_cvt_pk_u16_u32(0x10000, 0x1234)` = `0x1234FFFF`. 2. A 32-bit literal read through `op_sel` on a VOP3 16-bit op gives its high half, as LLVM's `add.v2i16.ll` shows for the packed form. 3. Clamp on the 16-bit add/sub/mad, on `v_add/sub_nc_i32` and `v_mad_u32_u16`/`v_mad_i32_i16`, and clamp as a no-op on `v_pk_max/min`, follow from §6.5 and LLVM rather than from a measurement. 4. Refused until measured: `clamp` on `v_mul_lo_u16` / `v_pk_mul_lo_u16` (the PDF says `V_MUL_LO_U16` "Supports saturation", but whether that saturates the full product is not stated), the 16-bit shifts, VOP3 min/max/min3/max3/med3, the packs and the packed shifts; `op_sel[2]`/`op_sel[3]` on `v_mad_u32_u16`/`v_mad_i32_i16`. `v_sad_u16` is left out of this PR. ## Checklist - [x] The PR covers a single reviewable behaviour. (One instruction family: the 16-bit integer VALU, VOP3 and packed.) - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Unmeasured forms raise `Untranslated` / `Untranslatable` naming the instruction and the modifier.) - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. Made with AI assistance: Claude Code with Claude Opus 5.5, for KainanP. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KainanP commented 2026-11-25 20:17:36 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-25T20:17:36Z.


Measurement request for the open assumptions above (pack saturation, op_sel on a 32-bit literal, unmeasured 16-bit clamp): akimfomin/PortBridge#84. (Edited 2026-11-25: a citation of the deleted Leonida docs removed; v_sad_u16 is not part of this PR.)

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7173454107 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/232#issuecomment-7173454107). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T20:17:36Z. --- Measurement request for the open assumptions above (pack saturation, op_sel on a 32-bit literal, unmeasured 16-bit `clamp`): akimfomin/PortBridge#84. (Edited 2026-11-25: a citation of the deleted Leonida docs removed; `v_sad_u16` is not part of this PR.)
LooperSalty commented 2026-11-25 21:03:03 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-25T21:03:03Z.


Thanks, the 16-bit VALU and packed VOP3P work is solid (96 tests fail without the change, README count matches).

The docstrings cite measurements from the Leonida project (ubiquitarianism/leonida, docs/design.md and docs/shader_validation.md at 9f9a7c5f). That repository was taken down on 2026-11-24 after a DMCA notice, and rule 2 of AGENTS.md only allows public sources (AMD's RDNA 2 ISA, LLVM's tests, Microsoft Learn, compatibly licensed code) and measurements from our own runs. Please remove these Leonida citations and, where a behaviour still needs a source, cite the AMD ISA section or an LLVM test instead (or re-measure it with our own tooling and say how it was obtained).

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7174541757 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/232#issuecomment-7174541757). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-25T21:03:03Z. --- Thanks, the 16-bit VALU and packed VOP3P work is solid (96 tests fail without the change, README count matches). The docstrings cite measurements from the Leonida project (ubiquitarianism/leonida, docs/design.md and docs/shader_validation.md at 9f9a7c5f). That repository was taken down on 2026-11-24 after a DMCA notice, and rule 2 of AGENTS.md only allows public sources (AMD's RDNA 2 ISA, LLVM's tests, Microsoft Learn, compatibly licensed code) and measurements from our own runs. Please remove these Leonida citations and, where a behaviour still needs a source, cite the AMD ISA section or an LLVM test instead (or re-measure it with our own tooling and say how it was obtained).
LooperSalty commented 2026-11-25 21:45:36 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-25T21:45:36Z.


Follow-up after the review: rdna2_exec_int16.py:29-31 attributes measurements to the Leonida project; please remove that attribution (cite the AMD ISA or LLVM, or label the behaviour as assumed). Then rebase on main and recount the README RDNA 2 line with rdna2_exec.coverage() on the merged tree. The rest looks good (tests fail without the change).

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7175502884 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/232#issuecomment-7175502884). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-25T21:45:36Z. --- Follow-up after the review: `rdna2_exec_int16.py:29-31` attributes measurements to the Leonida project; please remove that attribution (cite the AMD ISA or LLVM, or label the behaviour as assumed). Then rebase on main and recount the README RDNA 2 line with `rdna2_exec.coverage()` on the merged tree. The rest looks good (tests fail without the change).
KainanP commented 2026-11-25 22:54:20 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-25T22:54:20Z.


Thanks. Updated and rebased on main e921268 (one commit, 40aae0f):

  • Leonida is gone from the code, tests, commit message and description. Each behaviour now has a public source, or is labelled assumed, or is refused:
    • op_sel halves: ISA §13.3 tables 82/86 (p. 258, 263) and §6.2.5 table 21 (p. 44).
    • The other half of D is kept: ISA §12.12 for v_mad_u16/i16, plus LLVM 20.1.8 GCNSubtarget.cpp, "On gfx10, all 16-bit instructions preserve the high bits".
    • Clamp saturation: ISA "Supports saturation" and §6.5, plus LLVM uaddsat/usubsat/saddsat/ssubsat.ll on GFX10 (ssubsat → v_sub_nc_i16 … clamp, so the saturation is signed).
    • Clamp as a no-op on packed max/min: §6.5 (the result is one of its in-range inputs).
    • Constants split like a register: LLVM AMDGPUBaseInfo.cpp getInlineEncodingV216 and add.v2i16.ll (GFX10).
  • Without a source, so now refused by name: clamp on v_pk_mul_lo_u16 (the PDF marks V_MUL_LO_U16 "Supports saturation", which contradicts a no-op), and op_sel[2]/op_sel[3] on v_mad_u32_u16/v_mad_i32_i16. Still assumed: the pack saturation (Mesa/ACO) and a 32-bit literal under VOP3 op_sel. All of these are in akimfomin/PortBridge#84 (sections A, B, E).
  • The tests follow: no value is pinned as "measured" any more. The removed op_sel rows became refusal tests.
  • Also fixed: rdna2_hlsl_graphics.py did not include the int16 helpers, so a vertex or pixel shader using e.g. v_add_nc_i16 … clamp called an undefined AddSatI16 (dxc rejects that HLSL). A new vertex-shader test runs those ops on the GPU against the interpreter.
  • README recounted on the merged tree: 1,208 → 1,248 / 1,490 (84%), tests 1400+ → 1500+ (1,517 collected), in all 9 languages.

Checks: full suite on the RTX 4060 (1499 passed, 17 skipped); int16 and parity files on WARP (253 passed) and Intel UHD (253 passed); ruff clean.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7176922144 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/232#issuecomment-7176922144). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T22:54:20Z. --- Thanks. Updated and rebased on main `e921268` (one commit, `40aae0f`): - Leonida is gone from the code, tests, commit message and description. Each behaviour now has a public source, or is labelled assumed, or is refused: - op_sel halves: ISA §13.3 tables 82/86 (p. 258, 263) and §6.2.5 table 21 (p. 44). - The other half of D is kept: ISA §12.12 for `v_mad_u16/i16`, plus LLVM 20.1.8 `GCNSubtarget.cpp`, "On gfx10, all 16-bit instructions preserve the high bits". - Clamp saturation: ISA "Supports saturation" and §6.5, plus LLVM `uaddsat/usubsat/saddsat/ssubsat.ll` on GFX10 (`ssubsat` → `v_sub_nc_i16 … clamp`, so the saturation is signed). - Clamp as a no-op on packed max/min: §6.5 (the result is one of its in-range inputs). - Constants split like a register: LLVM `AMDGPUBaseInfo.cpp` `getInlineEncodingV216` and `add.v2i16.ll` (GFX10). - Without a source, so now refused by name: clamp on `v_pk_mul_lo_u16` (the PDF marks `V_MUL_LO_U16` "Supports saturation", which contradicts a no-op), and `op_sel[2]`/`op_sel[3]` on `v_mad_u32_u16`/`v_mad_i32_i16`. Still assumed: the pack saturation (Mesa/ACO) and a 32-bit literal under VOP3 op_sel. All of these are in akimfomin/PortBridge#84 (sections A, B, E). - The tests follow: no value is pinned as "measured" any more. The removed op_sel rows became refusal tests. - Also fixed: `rdna2_hlsl_graphics.py` did not include the int16 helpers, so a vertex or pixel shader using e.g. `v_add_nc_i16 … clamp` called an undefined `AddSatI16` (dxc rejects that HLSL). A new vertex-shader test runs those ops on the GPU against the interpreter. - README recounted on the merged tree: 1,208 → **1,248 / 1,490 (84%)**, tests 1400+ → **1500+** (1,517 collected), in all 9 languages. Checks: full suite on the RTX 4060 (1499 passed, 17 skipped); int16 and parity files on WARP (253 passed) and Intel UHD (253 passed); ruff clean. _AI use: Claude Code (Claude Opus 5.5)._
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
LooperSalty/AnyXboxX!232
No description provided.