shader: lower v_sad_u8 and v_sad_u16 #1649

Merged
rm-NoobInCoding merged 2 commits from upstream-pr/1656 into main 2026-11-24 17:36:16 +00:00
rm-NoobInCoding commented 2026-11-24 16:30:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rm-NoobInCoding on 2026-11-24T16:30:55Z.


Change

The integer table in tools/pixel_aot.py lowered three of the five sums of absolute differences (v_sad_hi_u8, v_sad_u32, v_msad_u8) and refused v_sad_u8 and v_sad_u16. This PR lowers the two remaining forms:

  • v_sad_u8: SAD_U8(S0, S1) + S2, the four byte-lane sum without the shift of v_sad_hi_u8, reusing the existing sad4_u8 helper;
  • v_sad_u16: ABSDIFF(S0[31:16], S1[31:16]) + ABSDIFF(S0[15:0], S1[15:0]) + S2, through a new sad2_u16 helper that is emitted only for a program that uses it.

Both are unsigned and modulo 2^32, as for the existing forms (AMD RDNA 2 ISA reference, VOP3 opcodes 346 and 348). The _e32 spelling, clamp, float modifiers, a wrong operand count and unwritten registers are refused, as for the rest of the family. v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8 and v_mqsad_u32_u8 stay refused.

The checks that pinned v_sad_u8 and v_sad_u16 as refused and uncovered (check_sad_lowering, the 16-bit ternary neighbours in tests/pixel_aot_check.py, and rejected_forms, sad_forms and the int16 neighbours in tests/form_coverage_check.py) now expect them accepted and covered. The forms that stay refused are still checked as refused. docs/experiments.md is updated.

Coverage: +2 gfx1013 and gfx1030 VOP3 forms (v_sad_u8, v_sad_u16).

Overlap: draft #531 lists v_sad_u8 and v_sad_u16 among a wider set of byte and funnel forms. This PR covers only these two SAD forms and does not touch the others #531 lists.

Verification

Base 578d1e1c, patch 87e48ad7. Windows 11 build 26300, dev preset, DXC 10.0.26100.0, NVIDIA GeForce RTX 4070 (driver 32.0.16.1714) and WARP.

ctest --preset dev --no-tests=error -R '^pixel_aot_sad_' --output-on-failure
python -B tests/pixel_aot_check.py
python -B tests/form_coverage_check.py
python -B tests/rdna2_tools_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
  • pixel_aot_sad_hardware and pixel_aot_sad_warp: 2/2 passed, no skips. Each now draws three groups: 35 draws from 3 compiles. The lanes group adds 13 draws: 2 rows plus 11 wrong references that must report pixel_mismatch.
  • The coverage records of both tests list v_sad_u8 and v_sad_u16.
  • rdna2_tools_check.py: 145 tests OK (18 skipped without LLVM). The shader scanner derives its integer patterns from pixel_aot.INTEGER, so test_supported_shader_instructions now expects v_sad_u8 and v_sad_u16 to be supported and keeps their _e32, clamp and short-operand spellings refused (second commit; the first CI run failed on this test).
  • All 49 platform-independent Python checks listed in AGENTS.md passed on the patch.
  • pixel_aot_check.py static controls, form_coverage_check.py (form coverage checks passed), docs links (16 files, 348 links) and bidi controls: passed.

Negative controls.

  • Dropping the high halfword lane from sad2_u16 makes pixel_aot_sad_warp fail. Every one of the 13 lanes cases reports mismatch, including the two right rows.
  • Lowering v_sad_u16 through sad4_u8 makes check_sad_lowering fail on the expected statement.

LLVM 15 round trip: not run locally (no LLVM with gfx1013 on this host); it passed in CI (Assemble and translate gfx1013 fixtures) on 78fc5c08. The new lines use the operand forms LLVM 15 already accepts for the sibling SAD instructions: three sources in the VOP3 encoding, at most two scalar registers and literals. The literal accumulator 0x3f800010 is not an inline constant.

Evidence and follow-up

All inputs are synthetic. The rows reuse the byte group's rows, whose halfwords also lie on both sides of 0x8000 (0xc100, 0x40c3), so the unsigned and signed halfword sums of the first row differ (0xffbc and 0xff42). Every input and expected result is a normal binary32 or zero, as the draw asserts. The draws show that the translated shader computes the documented operations on desktop GPUs, not that the console does.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586562183 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1656). Originally posted by [rm-NoobInCoding](https://github.com/rm-NoobInCoding) on 2026-11-24T16:30:55Z. --- ## Change The integer table in `tools/pixel_aot.py` lowered three of the five sums of absolute differences (`v_sad_hi_u8`, `v_sad_u32`, `v_msad_u8`) and refused `v_sad_u8` and `v_sad_u16`. This PR lowers the two remaining forms: - `v_sad_u8`: `SAD_U8(S0, S1) + S2`, the four byte-lane sum without the shift of `v_sad_hi_u8`, reusing the existing `sad4_u8` helper; - `v_sad_u16`: `ABSDIFF(S0[31:16], S1[31:16]) + ABSDIFF(S0[15:0], S1[15:0]) + S2`, through a new `sad2_u16` helper that is emitted only for a program that uses it. Both are unsigned and modulo 2^32, as for the existing forms (AMD RDNA 2 ISA reference, VOP3 opcodes 346 and 348). The `_e32` spelling, ` clamp`, float modifiers, a wrong operand count and unwritten registers are refused, as for the rest of the family. `v_qsad_pk_u16_u8`, `v_mqsad_pk_u16_u8` and `v_mqsad_u32_u8` stay refused. The checks that pinned `v_sad_u8` and `v_sad_u16` as refused and uncovered (`check_sad_lowering`, the 16-bit ternary neighbours in `tests/pixel_aot_check.py`, and `rejected_forms`, `sad_forms` and the int16 neighbours in `tests/form_coverage_check.py`) now expect them accepted and covered. The forms that stay refused are still checked as refused. `docs/experiments.md` is updated. Coverage: +2 gfx1013 and gfx1030 VOP3 forms (`v_sad_u8`, `v_sad_u16`). Overlap: draft #531 lists `v_sad_u8` and `v_sad_u16` among a wider set of byte and funnel forms. This PR covers only these two SAD forms and does not touch the others #531 lists. ## Verification Base `578d1e1c`, patch `87e48ad7`. Windows 11 build 26300, `dev` preset, DXC 10.0.26100.0, NVIDIA GeForce RTX 4070 (driver 32.0.16.1714) and WARP. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_sad_' --output-on-failure python -B tests/pixel_aot_check.py python -B tests/form_coverage_check.py python -B tests/rdna2_tools_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` - `pixel_aot_sad_hardware` and `pixel_aot_sad_warp`: 2/2 passed, no skips. Each now draws three groups: 35 draws from 3 compiles. The `lanes` group adds 13 draws: 2 rows plus 11 wrong references that must report `pixel_mismatch`. - The coverage records of both tests list `v_sad_u8` and `v_sad_u16`. - `rdna2_tools_check.py`: 145 tests OK (18 skipped without LLVM). The shader scanner derives its integer patterns from `pixel_aot.INTEGER`, so `test_supported_shader_instructions` now expects `v_sad_u8` and `v_sad_u16` to be supported and keeps their `_e32`, `clamp` and short-operand spellings refused (second commit; the first CI run failed on this test). - All 49 platform-independent Python checks listed in AGENTS.md passed on the patch. - `pixel_aot_check.py` static controls, `form_coverage_check.py` (`form coverage checks passed`), docs links (16 files, 348 links) and bidi controls: passed. **Negative controls.** - Dropping the high halfword lane from `sad2_u16` makes `pixel_aot_sad_warp` fail. Every one of the 13 `lanes` cases reports `mismatch`, including the two right rows. - Lowering `v_sad_u16` through `sad4_u8` makes `check_sad_lowering` fail on the expected statement. **LLVM 15 round trip:** not run locally (no LLVM with gfx1013 on this host); it passed in CI (`Assemble and translate gfx1013 fixtures`) on `78fc5c08`. The new lines use the operand forms LLVM 15 already accepts for the sibling SAD instructions: three sources in the VOP3 encoding, at most two scalar registers and literals. The literal accumulator `0x3f800010` is not an inline constant. ## Evidence and follow-up All inputs are synthetic. The rows reuse the byte group's rows, whose halfwords also lie on both sides of 0x8000 (`0xc100`, `0x40c3`), so the unsigned and signed halfword sums of the first row differ (`0xffbc` and `0xff42`). Every input and expected result is a normal binary32 or zero, as the draw asserts. The draws show that the translated shader computes the documented operations on desktop GPUs, not that the console does. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
tedin7 commented 2026-11-24 17:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:41:59Z.

Review: COMMENTED


Peer review of PR #1656 (shader: lower v_sad_u8 and v_sad_u16) at commit 87e48ad7.

Findings

No P1/P2 issues found.

  • RDNA2 semantics:
    • v_sad_u8 lowers to sad4_u8({0}, {1}, false) + {2} (4 unsigned byte absolute differences summed with src2 modulo 2^{32}, no saturation).
    • v_sad_u16 lowers to sad2_u16({0}, {1}) + {2} (2 unsigned 16-bit lane absolute differences summed with src2 modulo 2^{32}, no saturation).
  • VOP3 modifiers & validation: _e32, clamp, float modifiers, wrong operand counts, unwritten/out-of-range registers, and >32-bit literals are refused; sad4_u8 and sad2_u16 helpers are emitted only when referenced.
  • Coverage & tests: tests/form_coverage_check.py moves ("VOP3", "v_sad_u8") and ("VOP3", "v_sad_u16") into sad_forms and updates check_int16_ternary_forms; tests/pixel_aot_check.py adds the lanes group and negative controls.

Checks Executed

  • Linux:
    • /root/.venvs/x2w-tests/bin/python3 tests/form_coverage_check.py -> form coverage checks passed (exit 0)
    • PYTHONPATH=tests:tools /root/.venvs/x2w-tests/bin/python3 -c "import pathlib, tempfile, pixel_aot_check as p; ... p.check_controls(pathlib.Path(d))" -> check_controls OK (exit 0, includes check_sad_lowering)
    • llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -filetype=obj -o /dev/null on all SAD_BODIES (bytes, dword, lanes) -> exit 0
  • Local mutation check:
    • Temporarily changed "sad_u16" in tools/pixel_aot.py to sad4_u8({0}, {1}, false) + {2} and re-ran pixel_aot_check.check_sad_lowering() -> failed as expected with AssertionError: ('lanes', ' precise float alu23 = asfloat(sad2_u16(params[0].w, asuint(alu20)) + params[1].y);'). Restored with git checkout -- . and verified clean git status --short.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP, x2w_pipe.py win2025 1656 --targets offscreen_check --regex "pixel_aot_sad|pixel_aot_int16_ternary" --py-checks tests/form_coverage_check.py):
    • Debug (--preset dev): offscreen_check built (3.86s), ctest --preset dev -R 'pixel_aot_sad|pixel_aot_int16_ternary' 4/4 passed (2.95s: pixel_aot_sad_hardware, pixel_aot_sad_warp, pixel_aot_int16_ternary_hardware, pixel_aot_int16_ternary_warp; hardware tests excluded/WARP on VM).
    • Release /O2 (--preset release): offscreen_check built (1.53s), ctest --preset release -R 'pixel_aot_sad|pixel_aot_int16_ternary' 4/4 passed (2.98s: pixel_aot_sad_warp, pixel_aot_sad_hardware, pixel_aot_int16_ternary_hardware, pixel_aot_int16_ternary_warp).
    • Python check: tests/form_coverage_check.py -> passed (16.21s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043464953 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1656#pullrequestreview-6043464953). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:41:59Z. **Review:** COMMENTED --- Peer review of PR #1656 (`shader: lower v_sad_u8 and v_sad_u16`) at commit `87e48ad7`. ### Findings No P1/P2 issues found. - **RDNA2 semantics**: - `v_sad_u8` lowers to `sad4_u8({0}, {1}, false) + {2}` (4 unsigned byte absolute differences summed with `src2` modulo $2^{32}$, no saturation). - `v_sad_u16` lowers to `sad2_u16({0}, {1}) + {2}` (2 unsigned 16-bit lane absolute differences summed with `src2` modulo $2^{32}$, no saturation). - **VOP3 modifiers & validation**: `_e32`, `clamp`, float modifiers, wrong operand counts, unwritten/out-of-range registers, and >32-bit literals are refused; `sad4_u8` and `sad2_u16` helpers are emitted only when referenced. - **Coverage & tests**: `tests/form_coverage_check.py` moves `("VOP3", "v_sad_u8")` and `("VOP3", "v_sad_u16")` into `sad_forms` and updates `check_int16_ternary_forms`; `tests/pixel_aot_check.py` adds the `lanes` group and negative controls. ### Checks Executed - **Linux**: - `/root/.venvs/x2w-tests/bin/python3 tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `PYTHONPATH=tests:tools /root/.venvs/x2w-tests/bin/python3 -c "import pathlib, tempfile, pixel_aot_check as p; ... p.check_controls(pathlib.Path(d))"` -> `check_controls OK` (exit 0, includes `check_sad_lowering`) - `llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -filetype=obj -o /dev/null` on all `SAD_BODIES` (`bytes`, `dword`, `lanes`) -> exit 0 - **Local mutation check**: - Temporarily changed `"sad_u16"` in `tools/pixel_aot.py` to `sad4_u8({0}, {1}, false) + {2}` and re-ran `pixel_aot_check.check_sad_lowering()` -> failed as expected with `AssertionError: ('lanes', ' precise float alu23 = asfloat(sad2_u16(params[0].w, asuint(alu20)) + params[1].y);')`. Restored with `git checkout -- .` and verified clean `git status --short`. - **Windows Server 2025** (Build 26100, MSVC 14.44.35207 + D3D12 WARP, `x2w_pipe.py win2025 1656 --targets offscreen_check --regex "pixel_aot_sad|pixel_aot_int16_ternary" --py-checks tests/form_coverage_check.py`): - **Debug (`--preset dev`)**: `offscreen_check` built (`3.86s`), `ctest --preset dev -R 'pixel_aot_sad|pixel_aot_int16_ternary'` **4/4 passed** (`2.95s`: `pixel_aot_sad_hardware`, `pixel_aot_sad_warp`, `pixel_aot_int16_ternary_hardware`, `pixel_aot_int16_ternary_warp`; hardware tests excluded/WARP on VM). - **Release `/O2` (`--preset release`)**: `offscreen_check` built (`1.53s`), `ctest --preset release -R 'pixel_aot_sad|pixel_aot_int16_ternary'` **4/4 passed** (`2.98s`: `pixel_aot_sad_warp`, `pixel_aot_sad_hardware`, `pixel_aot_int16_ternary_hardware`, `pixel_aot_int16_ternary_warp`). - **Python check**: `tests/form_coverage_check.py` -> passed (`16.21s`). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 18:02:21 +00:00
tedin7 commented 2026-11-24 18:02:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:03:53Z.

Review: COMMENTED


Re-review at head_sha: 78fc5c08f91efbead6f0c353a72c79380bb9e862 (new commit 78fc5c08 on top of 87e48ad7).

Findings

No P1/P2. The new commit only touches tests/rdna2_tools_check.py and makes the scanner test match the translator change.

  • The scanner test used to list v_sad_u8 and v_sad_u16 as unsupported. It now expects is_instruction_supported for v_sad_u8 v1, v2, v3, v4 and v_sad_u16 v1, s2, v3, 64, and keeps refusing _e32, clamp, a missing operand and v_sad_u16 ... clamp. is_opcode_recognized gains both opcodes.
  • The old test cannot pass against the new translator: I ran the previous head's version of test_supported_shader_instructions against this head's tools/ and it fails. So this commit fixes a real failing check, not just a tidy-up.

Verified

Linux only, x86-64 (no Windows/D3D12 run this time):

  • PYTHONPATH=tests:tools python -m unittest rdna2_tools_check.TestRdna2Scanner.test_supported_shader_instructions -> OK.
  • python tests/form_coverage_check.py -> form coverage checks passed.
  • pixel_aot_check.check_controls (includes check_sad_lowering) -> OK.
  • llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encoding: v_sad_u8 v1, v2, v3, v4 -> 01 00 5a d5 02 07 12 04; v_sad_u16 v1, s2, v3, 64 -> 01 00 5c d5 02 06 02 03; v_sad_u16 v1, v2, v3, v4 clamp assembles (clamp bit set), and the PR refuses it.
  • Mutation: deleted the "sad_u8" entry from INTEGER in tools/pixel_aot.py; the scanner test fails with AssertionError: False is not true : v_sad_u8 v1, v2, v3, v4. Restored; git status --short clean.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043806441 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1656#pullrequestreview-6043806441). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:03:53Z. **Review:** COMMENTED --- Re-review at `head_sha`: `78fc5c08f91efbead6f0c353a72c79380bb9e862` (new commit `78fc5c08` on top of `87e48ad7`). ### Findings No P1/P2. The new commit only touches `tests/rdna2_tools_check.py` and makes the scanner test match the translator change. - The scanner test used to list `v_sad_u8` and `v_sad_u16` as unsupported. It now expects `is_instruction_supported` for `v_sad_u8 v1, v2, v3, v4` and `v_sad_u16 v1, s2, v3, 64`, and keeps refusing `_e32`, `clamp`, a missing operand and `v_sad_u16 ... clamp`. `is_opcode_recognized` gains both opcodes. - The old test cannot pass against the new translator: I ran the previous head's version of `test_supported_shader_instructions` against this head's `tools/` and it fails. So this commit fixes a real failing check, not just a tidy-up. ### Verified Linux only, x86-64 (no Windows/D3D12 run this time): - `PYTHONPATH=tests:tools python -m unittest rdna2_tools_check.TestRdna2Scanner.test_supported_shader_instructions` -> OK. - `python tests/form_coverage_check.py` -> `form coverage checks passed`. - `pixel_aot_check.check_controls` (includes `check_sad_lowering`) -> OK. - `llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encoding`: `v_sad_u8 v1, v2, v3, v4` -> `01 00 5a d5 02 07 12 04`; `v_sad_u16 v1, s2, v3, 64` -> `01 00 5c d5 02 06 02 03`; `v_sad_u16 v1, v2, v3, v4 clamp` assembles (clamp bit set), and the PR refuses it. - **Mutation:** deleted the `"sad_u8"` entry from `INTEGER` in `tools/pixel_aot.py`; the scanner test fails with `AssertionError: False is not true : v_sad_u8 v1, v2, v3, v4`. Restored; `git status --short` clean. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 18:02:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:28:18Z.

Review: COMMENTED


Verified at head_sha: 78fc5c08f91efbead6f0c353a72c79380bb9e862 (0 P1, 0 P2).

Scope & Semantics

  • Touches only tools/pixel_aot.py, tests/pixel_aot_check.py, tests/form_coverage_check.py, tests/rdna2_tools_check.py, and docs/experiments.md.
  • v_sad_u8 (sad4_u8(a, b, false) + c) and v_sad_u16 (sad2_u16(a, b) + c) match the AMD RDNA 2 ISA definitions (VOP3 opcodes 346 and 348, unsigned lane absolute differences summed modulo 2^32); VOP3-only guards reject _e32, clamp, float modifiers, and wrong operand counts.

Verified

  • Linux:
    • git diff --check origin/main...HEAD -> clean
    • python3 tests/docs_links_check.py -> passed (16 Markdown files, 348 links)
    • python3 tests/bidi_controls_check.py -> passed (1276 tracked files)
    • PYTHONPATH=tests:tools python3 -m unittest rdna2_tools_check.TestRdna2Scanner.test_supported_shader_instructions -> OK
    • pixel_aot_check.check_sad_lowering() -> OK
    • llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encoding: v_sad_u8 v12, s44, v18, s46 (0c 00 5a d5 2c 24 ba 00), v_sad_u16 v14, s44, v18, s46 (0e 00 5c d5 2c 24 ba 00)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): offscreen_check built (10.49s), ctest --preset dev -R 'pixel_aot_sad|pixel_aot_int16_ternary' 4/4 passed (3.01s: pixel_aot_sad_hardware, pixel_aot_sad_warp, pixel_aot_int16_ternary_warp, pixel_aot_int16_ternary_hardware)
    • Release /O2 (--preset release): offscreen_check built (8.17s), ctest --preset release -R 'pixel_aot_sad|pixel_aot_int16_ternary' 4/4 passed (3.09s)
    • Windows Python check: tests/form_coverage_check.py -> passed (16.76s)
  • Mutation checks (local, reverted cleanly):
    • Shifted sad_u8 by << 16u in tools/pixel_aot.py -> pixel_aot_check.check_sad_lowering() failed as expected (AssertionError on lanes alu21).
    • Removed "sad_u16" from SAD_HELPERS in tools/pixel_aot.py -> pixel_aot_check.check_sad_lowering() failed as expected (sad2_u16 helper count mismatch).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044184057 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1656#pullrequestreview-6044184057). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:28:18Z. **Review:** COMMENTED --- Verified at `head_sha`: `78fc5c08f91efbead6f0c353a72c79380bb9e862` (0 P1, 0 P2). ### Scope & Semantics - Touches only `tools/pixel_aot.py`, `tests/pixel_aot_check.py`, `tests/form_coverage_check.py`, `tests/rdna2_tools_check.py`, and `docs/experiments.md`. - `v_sad_u8` (`sad4_u8(a, b, false) + c`) and `v_sad_u16` (`sad2_u16(a, b) + c`) match the AMD RDNA 2 ISA definitions (VOP3 opcodes 346 and 348, unsigned lane absolute differences summed modulo 2^32); VOP3-only guards reject `_e32`, `clamp`, float modifiers, and wrong operand counts. ### Verified - **Linux**: - `git diff --check origin/main...HEAD` -> clean - `python3 tests/docs_links_check.py` -> passed (16 Markdown files, 348 links) - `python3 tests/bidi_controls_check.py` -> passed (1276 tracked files) - `PYTHONPATH=tests:tools python3 -m unittest rdna2_tools_check.TestRdna2Scanner.test_supported_shader_instructions` -> OK - `pixel_aot_check.check_sad_lowering()` -> OK - `llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encoding`: `v_sad_u8 v12, s44, v18, s46` (`0c 00 5a d5 2c 24 ba 00`), `v_sad_u16 v14, s44, v18, s46` (`0e 00 5c d5 2c 24 ba 00`) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: `offscreen_check` built (`10.49s`), `ctest --preset dev -R 'pixel_aot_sad|pixel_aot_int16_ternary'` **4/4 passed** (`3.01s`: `pixel_aot_sad_hardware`, `pixel_aot_sad_warp`, `pixel_aot_int16_ternary_warp`, `pixel_aot_int16_ternary_hardware`) - **Release `/O2` (`--preset release`)**: `offscreen_check` built (`8.17s`), `ctest --preset release -R 'pixel_aot_sad|pixel_aot_int16_ternary'` **4/4 passed** (`3.09s`) - **Windows Python check**: `tests/form_coverage_check.py` -> passed (`16.76s`) - **Mutation checks** (local, reverted cleanly): - Shifted `sad_u8` by `<< 16u` in `tools/pixel_aot.py` -> `pixel_aot_check.check_sad_lowering()` failed as expected (`AssertionError` on `lanes` `alu21`). - Removed `"sad_u16"` from `SAD_HELPERS` in `tools/pixel_aot.py` -> `pixel_aot_check.check_sad_lowering()` failed as expected (`sad2_u16` helper count mismatch). AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-24 18:03:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T17:58:13Z.


The lowering table is exercised; three mutants fail

Ran this at 78fc5c08:

out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py        -> exit 0
out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py    -> form coverage checks passed
out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py      -> OK (skipped=18)

Mutation check on the new entries

Three changes to SAD_LOWERING in tools/pixel_aot.py, each restored afterwards:

change result
sad_u16 lowered with sad4_u8 instead of sad2_u16 caught — RuntimeError: Control sub-check ('fn', 'check_sad_lowering') failed
sad_u8 drops the accumulator {2} caught, same control
msad_u8's masked form flipped from true to false caught, same control

So the three behaviours this patch adds are each pinned by a named sub-check, and the failure message says which one. That is
better than most of the lowering tables in this tool: check_sad_lowering reports the failing form rather than a generic
mismatch.

Two things worth stating in the PR body

  1. rdna2_tools_check still skips 18 tests (LLVM_LIB unset), and those are the ones that disassemble against LLVM
    rather than against hand-written expectations. If the v_sad_u8 / v_sad_u16 encodings in this patch were checked
    against a real llvm-mc, a line with the version and the printed mnemonic would make that checkable for everyone
    else. Same point as #1661 — not a blocker, just the one claim a reader cannot verify from CI.
  2. sad_u16 uses sad2_u16 while sad_hi_u8 reuses sad4_u8. Worth one sentence in docs/experiments.md saying
    which helper each form maps to, since the table is the only place that fact lives and it is easy to mis-edit — that is
    exactly what my first mutant did, and only the control caught it.

Otherwise

form_coverage_check.py picks up the new opcodes, the doc entry is in the same patch, and nothing else in the diff looked
loose.

Verdict

Reviewed 78fc5c08. The lowering is correct as far as the fixtures go, and all three forms are guarded by mutation. No
objections.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139967467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1656#issuecomment-7139967467). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:58:13Z. --- ## The lowering table is exercised; three mutants fail Ran this at `78fc5c08`: ```powershell out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py -> exit 0 out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py -> form coverage checks passed out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py -> OK (skipped=18) ``` ## Mutation check on the new entries Three changes to `SAD_LOWERING` in `tools/pixel_aot.py`, each restored afterwards: | change | result | |---|---| | `sad_u16` lowered with `sad4_u8` instead of `sad2_u16` | **caught** — `RuntimeError: Control sub-check ('fn', 'check_sad_lowering') failed` | | `sad_u8` drops the accumulator `{2}` | **caught**, same control | | `msad_u8`'s masked form flipped from `true` to `false` | **caught**, same control | So the three behaviours this patch adds are each pinned by a named sub-check, and the failure message says which one. That is better than most of the lowering tables in this tool: `check_sad_lowering` reports the failing form rather than a generic mismatch. ## Two things worth stating in the PR body 1. **`rdna2_tools_check` still skips 18 tests** (`LLVM_LIB` unset), and those are the ones that disassemble against LLVM rather than against hand-written expectations. If the `v_sad_u8` / `v_sad_u16` encodings in this patch were checked against a real `llvm-mc`, a line with the version and the printed mnemonic would make that checkable for everyone else. Same point as #1661 — not a blocker, just the one claim a reader cannot verify from CI. 2. `sad_u16` uses `sad2_u16` while `sad_hi_u8` reuses `sad4_u8`. Worth one sentence in `docs/experiments.md` saying which helper each form maps to, since the table is the only place that fact lives and it is easy to mis-edit — that is exactly what my first mutant did, and only the control caught it. ## Otherwise `form_coverage_check.py` picks up the new opcodes, the doc entry is in the same patch, and nothing else in the diff looked loose. ## Verdict Reviewed `78fc5c08`. The lowering is correct as far as the fixtures go, and all three forms are guarded by mutation. No objections. ## Notes - AI-assisted review.
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
R0Y00/Xbox2Windows!1649
No description provided.