shader: lower the remaining no-carry 32-bit add and sub forms in pixel_aot #582

Manually merged
github merged 3 commits from gh-pr/582/head into gh-pr/582/base 2026-11-26 22:03:39 +00:00
Owner

@⁠JB2WIN on GitHub · 2026-11-22 14:06 UTC · original
JB2WIN:shader/add-sub-nc → main · +180 −17 · 6 files · 3 commits · merged 2026-11-22 15:08 UTC

Change

tools/pixel_aot.py now lowers the remaining 32-bit no-carry add/sub forms. This builds on #495 (VOP2 v_add/sub_nc_u32_e32) and #570 (v_subrev_nc_u32_e32):

  • v_add_nc_u32_e64, v_sub_nc_u32_e64, v_subrev_nc_u32_e64
  • the VOP3-only v_add_nc_i32 and v_sub_nc_i32, in the unsuffixed spelling LLVM 15 prints. These are 32-bit wraparound with no clamp, so they produce the same bits as the u32 forms.

The add/sub/subrev lowering is now one table branch (subrev = b - a) instead of #570's separate subrev branch. #570's check_subrev_u32_draw is unchanged.

Refused and tested as rejections, each paired with its accepted spelling:

  • clamp on these forms
  • abs/neg on an e64 source
  • v_add_nc_i32_e64: the explicit suffix is not the printed form, and gfx1013.tsv has no row for it
  • SDWA
  • DPP controls other than quad_perm/dpp8, which the existing DPP table already lowers

Float-written inline constants are taken as their binary32 bits, as for the #495 forms. This is now pinned for 1.0 and -1.0. The scanner pattern and KNOWN_RDNA2_BASE_OPCODES cover the family. The scanner's INTEGER_SOURCE class is coarser than the translator and also accepts v106, as before.

Changed expectation: the e64 rows in the bad_vop2 rejection list (from #495/#570) are removed because e64 is now accepted. The new static group asserts their lowering.

Semantics: subrev = src1 − src0 follows the translator's existing convention. It matches LLVM 15 TableGen (VOP2Instructions.td: V_SUBREV_U32 has revOp v_sub_u32, and the REV patterns swap operands; gfx10 V_SUBREV_NC_U32 encodes that pseudo). The draws check consistency with this convention on desktop GPUs. I could not check it against the RDNA 2 ISA PDF.

AI-assisted (Claude Code).

Verification

Head is rebased on bbebcad. Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124, debug layer on) and WARP 10.0.26100.9818.

  • New mode draw-integer-nc with CTest pixel_aot_integer_nc_{hardware,warp} (about 3.3 s / 0.8 s). It uses lossless integer readback and 11 draws: 3 groups × 5 rows (A, B). Every input and result is a normal binary32 pattern or ±0, and the test asserts this. The rows cover unsigned wrap, signed overflow, borrow, sub ≠ subrev, high-bit wrap, inline constants and VGPR-first operands.
  • Negative control: swapping the sub/subrev expected words gives pixel_mismatch on both adapters. Dev-time mutation (subrev as a - b) fails both tests and was reverted.
  • ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)": 22/22.
  • Full ctest --preset dev --no-tests=error (on d4c7656, before the last trivial rebase): 279 tests, 0 failed. Skips: bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp.
  • tests/pixel_aot_check.py binary with LLVM 15.0.7, locally: exit 0. tests/pixel_aot_check.py (controls), rdna2_tools_check.py, form_coverage_check.py and docs_links_check.py all pass.

Evidence and follow-up

  • Synthetic shader literals and constants only. No game data.
  • Possible textual overlap with #576 (it also edits KNOWN_RDNA2_BASE_OPCODES).
  • dashboard.svg is not regenerated.

🤖 Generated with Claude Code

**@⁠JB2WIN** on GitHub · 2026-11-22 14:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/582) `JB2WIN:shader/add-sub-nc` → `main` · +180 −17 · 6 files · 3 commits · merged 2026-11-22 15:08 UTC ## Change `tools/pixel_aot.py` now lowers the remaining 32-bit no-carry add/sub forms. This builds on #495 (VOP2 `v_add/sub_nc_u32_e32`) and #570 (`v_subrev_nc_u32_e32`): - `v_add_nc_u32_e64`, `v_sub_nc_u32_e64`, `v_subrev_nc_u32_e64` - the VOP3-only `v_add_nc_i32` and `v_sub_nc_i32`, in the unsuffixed spelling LLVM 15 prints. These are 32-bit wraparound with no clamp, so they produce the same bits as the u32 forms. The add/sub/subrev lowering is now one table branch (subrev = `b - a`) instead of #570's separate subrev branch. #570's `check_subrev_u32_draw` is unchanged. Refused and tested as rejections, each paired with its accepted spelling: - ` clamp` on these forms - `abs`/`neg` on an e64 source - `v_add_nc_i32_e64`: the explicit suffix is not the printed form, and `gfx1013.tsv` has no row for it - SDWA - DPP controls other than `quad_perm`/`dpp8`, which the existing DPP table already lowers Float-written inline constants are taken as their binary32 bits, as for the #495 forms. This is now pinned for `1.0` and `-1.0`. The scanner pattern and `KNOWN_RDNA2_BASE_OPCODES` cover the family. The scanner's `INTEGER_SOURCE` class is coarser than the translator and also accepts `v106`, as before. **Changed expectation:** the e64 rows in the `bad_vop2` rejection list (from #495/#570) are removed because e64 is now accepted. The new static group asserts their lowering. Semantics: `subrev` = src1 − src0 follows the translator's existing convention. It matches LLVM 15 TableGen (`VOP2Instructions.td`: `V_SUBREV_U32` has revOp `v_sub_u32`, and the REV patterns swap operands; gfx10 `V_SUBREV_NC_U32` encodes that pseudo). The draws check consistency with this convention on desktop GPUs. I could not check it against the RDNA 2 ISA PDF. AI-assisted (Claude Code). ## Verification Head is rebased on `bbebcad`. Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124, debug layer on) and WARP 10.0.26100.9818. - New mode `draw-integer-nc` with CTest `pixel_aot_integer_nc_{hardware,warp}` (about 3.3 s / 0.8 s). It uses lossless integer readback and 11 draws: 3 groups × 5 rows (A, B). Every input and result is a normal binary32 pattern or ±0, and the test asserts this. The rows cover unsigned wrap, signed overflow, borrow, sub ≠ subrev, high-bit wrap, inline constants and VGPR-first operands. - Negative control: swapping the sub/subrev expected words gives `pixel_mismatch` on both adapters. Dev-time mutation (subrev as `a - b`) fails both tests and was reverted. - `ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)"`: 22/22. - Full `ctest --preset dev --no-tests=error` (on `d4c7656`, before the last trivial rebase): 279 tests, 0 failed. Skips: `bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp`. - `tests/pixel_aot_check.py binary` with LLVM 15.0.7, locally: exit 0. `tests/pixel_aot_check.py` (controls), `rdna2_tools_check.py`, `form_coverage_check.py` and `docs_links_check.py` all pass. ## Evidence and follow-up - Synthetic shader literals and constants only. No game data. - Possible textual overlap with #576 (it also edits `KNOWN_RDNA2_BASE_OPCODES`). - `dashboard.svg` is not regenerated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Lower v_subrev_nc_u32 (e32 and e64), v_add_nc_u32_e64, v_sub_nc_u32_e64 and
the VOP3-only v_add_nc_i32 and v_sub_nc_i32 with 32-bit wraparound. Clamp,
operand modifiers, DPP, SDWA and the hand-written v_*_nc_i32_e64 spelling stay
rejected. The two e64 rows that the previous check refused are now accepted.

Three programs draw the forms bit for bit through the integer readback target
(11 draws, own CTest entry pixel_aot_integer_nc_{hardware,warp}), with a
swapped sub/subrev negative control. The LLVM 15 round trip covers them and the
scanner pattern and known-opcode list are extended.

Subrev computes src1 - src0, following the translator's float subrev
convention; the draws check consistency with it, not the ISA document.

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