shader: lower integer v_cmpx region openers #1328

Merged
archielcqp-a11y merged 1 commit from upstream-pr/1335 into main 2026-11-24 08:55:53 +00:00
archielcqp-a11y commented 2026-11-24 08:27:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-24T08:27:37Z.


Change

The v_cmpx region opener (issue #932) accepted the VOPC e32 forms on binary32 and on 32-bit integers. It now also accepts the e32 forms on 16-bit integers (eq, ne, lt, le, gt, ge for i16 and u16; gfx10 has no 16-bit f or t) and on 64-bit integers (all eight predicates for i64 and u64). That is 28 more forms. The region rules are unchanged: the save must come directly before the compare, the close is an s_mov_b64 or s_or_b64 restore, and the optional skip is allowed. Only the compare is new.

  • 16-bit forms read their operands through the existing int16_operand, which compares the low 16 bits with sign extension or masking. These are the same semantics as the 16-bit v_cmp draws.
  • 64-bit forms use a new int64_comparison helper, factored out of the 64-bit v_cmp branch and now shared by both. The operand rules are the same as for the 64-bit v_cmp, and VSRC1 must be a VGPR pair.
  • e64, SDWA, binary16, binary64 and class v_cmpx forms stay refused.

Refs #932.

Verification

Commit 9d0e43e on upstream 0f09ca9, Windows 10 build 19045.6466. NVIDIA GeForce RTX 3080 (10de:2216), driver 32.0.15.9174, and WARP 1.0.22 (Agility SDK 1.620.2), with the debug layer enabled.

  • ctest --test-dir out/build/w10 --no-tests=error -R '^pixel_aot_(cmpx_regions|cmp64|comparisons)_': 6/6 passed on WARP and hardware, with no skips.
  • python -B tests/pixel_aot_check.py binary <llvm-mc 15> <llvm-objcopy 15> <LLVM-C.dll 15>: exit 0. This runs the translator controls and the LLVM 15 gfx1013 round trip, which now includes the four 64-bit v_cmpx programs.
  • All 39 pure-Python checks from AGENTS.md pass, including form_coverage_check, rdna2_tools_check and docs_links_check.
  • tools/form_coverage.py was run on a JUnit run of the 153 record-writing tests, all of which passed. gfx1013 coverage went from 960 to 988 of 1968 forms (+28), and no v_cmpx_*_{i16,u16,i64,u64} VOPC gap remains. gfx1030 coverage is 978 of 1863.

Fixtures and negative controls

  • Draws (pixel_aot_cmpx_regions_{warp,hardware}):
    • Four new 16-bit predicate groups. They run on operand pairs whose high halves disagree with their low halves, so a 32-bit comparison would give different results.
    • Four new 64-bit groups. These run each predicate over the operand shapes and word patterns of the 64-bit v_cmp draws, against the same cmp64 reference.
  • Mismatch controls: each of these must mismatch:
    • a signed 16-bit reference read as unsigned;
    • a signed 16-bit reference compared over all 32 bits;
    • the signed 64-bit shader drawn against the unsigned reference.
  • Translator controls:
    • Equivalence: a 16-bit v_cmpx lowers to the same predicate as the matching v_cmp.
    • Rejections: v_cmpx_t_i16, a float literal on a 16-bit operand, an SGPR pair or 32-bit VGPR as the 64-bit VSRC1, and the e64 spelling.
    • Two existing controls that listed these forms as unknown instructions (check_cmp64_controls, form_coverage_check) now expect the region rule instead. v_cmpx_lt_i64_e32 without an exec save must fail with Unsupported v_cmpx execution mask save. The binary16, class and binary64 neighbours stay asserted as uncovered.

What remains a hypothesis: the EXEC intersection rule comes from the ISA text, as it did for the existing opener forms. No gfx1013 hardware run checks it.

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.

This change was AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577707212 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1335). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-24T08:27:37Z. --- ## Change The `v_cmpx` region opener (issue #932) accepted the VOPC e32 forms on binary32 and on 32-bit integers. It now also accepts the e32 forms on 16-bit integers (`eq`, `ne`, `lt`, `le`, `gt`, `ge` for `i16` and `u16`; gfx10 has no 16-bit `f` or `t`) and on 64-bit integers (all eight predicates for `i64` and `u64`). That is 28 more forms. The region rules are unchanged: the save must come directly before the compare, the close is an `s_mov_b64` or `s_or_b64` restore, and the optional skip is allowed. Only the compare is new. - 16-bit forms read their operands through the existing `int16_operand`, which compares the low 16 bits with sign extension or masking. These are the same semantics as the 16-bit `v_cmp` draws. - 64-bit forms use a new `int64_comparison` helper, factored out of the 64-bit `v_cmp` branch and now shared by both. The operand rules are the same as for the 64-bit `v_cmp`, and VSRC1 must be a VGPR pair. - e64, SDWA, binary16, binary64 and class `v_cmpx` forms stay refused. Refs #932. ## Verification Commit `9d0e43e` on upstream `0f09ca9`, Windows 10 build 19045.6466. NVIDIA GeForce RTX 3080 (10de:2216), driver 32.0.15.9174, and WARP 1.0.22 (Agility SDK 1.620.2), with the debug layer enabled. - `ctest --test-dir out/build/w10 --no-tests=error -R '^pixel_aot_(cmpx_regions|cmp64|comparisons)_'`: 6/6 passed on WARP and hardware, with no skips. - `python -B tests/pixel_aot_check.py binary <llvm-mc 15> <llvm-objcopy 15> <LLVM-C.dll 15>`: exit 0. This runs the translator controls and the LLVM 15 gfx1013 round trip, which now includes the four 64-bit `v_cmpx` programs. - All 39 pure-Python checks from AGENTS.md pass, including `form_coverage_check`, `rdna2_tools_check` and `docs_links_check`. - `tools/form_coverage.py` was run on a JUnit run of the 153 record-writing tests, all of which passed. gfx1013 coverage went from 960 to 988 of 1968 forms (+28), and no `v_cmpx_*_{i16,u16,i64,u64}` VOPC gap remains. gfx1030 coverage is 978 of 1863. ## Fixtures and negative controls - **Draws (`pixel_aot_cmpx_regions_{warp,hardware}`):** - Four new 16-bit predicate groups. They run on operand pairs whose high halves disagree with their low halves, so a 32-bit comparison would give different results. - Four new 64-bit groups. These run each predicate over the operand shapes and word patterns of the 64-bit `v_cmp` draws, against the same `cmp64` reference. - **Mismatch controls:** each of these must mismatch: - a signed 16-bit reference read as unsigned; - a signed 16-bit reference compared over all 32 bits; - the signed 64-bit shader drawn against the unsigned reference. - **Translator controls:** - Equivalence: a 16-bit `v_cmpx` lowers to the same predicate as the matching `v_cmp`. - Rejections: `v_cmpx_t_i16`, a float literal on a 16-bit operand, an SGPR pair or 32-bit VGPR as the 64-bit VSRC1, and the e64 spelling. - Two existing controls that listed these forms as unknown instructions (`check_cmp64_controls`, `form_coverage_check`) now expect the region rule instead. `v_cmpx_lt_i64_e32` without an exec save must fail with `Unsupported v_cmpx execution mask save`. The binary16, class and binary64 neighbours stay asserted as uncovered. What remains a hypothesis: the EXEC intersection rule comes from the ISA text, as it did for the existing opener forms. No gfx1013 hardware run checks it. ## 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. This change was AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 09:04:35 +00:00
tedin7 commented 2026-11-24 09:04:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:45:43Z.

Review: COMMENTED


Reviewed at commit 9d0e43ee5bc80be1c96db933fa42bcde2ca8f12b.

Linux Checks

  • git diff --check origin/main...HEAD: passed (no whitespace/conflict-marker issues).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (Checked 16 Markdown files and 294 links.).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (Checked 1108 tracked source, script and build/CI files: no bidirectional controls.).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py: passed (Ran 138 tests ... OK (skipped=18)).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: passed (form coverage checks passed).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py (pure-Python mode): passed (exit 0).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: failed in unrelated existing check_f16_cvt_int16_binary (v_cvt_f16_i16_e32 v1, 0xfff0, LLVM-19 vs LLVM-15 encoding/spelling expectation).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Windows Python checks: tests/form_coverage_check.py passed (39.26s).
  • Debug (--preset dev):
    • Build (offscreen_check): 36.02s (configure 1.53s)
    • ctest --preset dev -R '^(pixel_aot_cmpx_regions_warp|pixel_aot_comparisons_warp|pixel_aot_cmp64_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (pixel_aot_cmp64_warp 3.34s, pixel_aot_cmpx_regions_warp 3.64s, pixel_aot_comparisons_warp 7.49s)
  • Release /O2 (--preset release):
    • Build (offscreen_check): 52.12s (configure 1.58s)
    • ctest --preset release -R '^(pixel_aot_cmpx_regions_warp|pixel_aot_comparisons_warp|pixel_aot_cmp64_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (pixel_aot_cmp64_warp 3.08s, pixel_aot_cmpx_regions_warp 3.47s, pixel_aot_comparisons_warp 7.30s)

Code Review Notes

  • tools/pixel_aot.py: cleanly extends VOPC _e32 v_cmpx region openers to 16-bit (eq/ne/lt/le/gt/ge on i16/u16 via int16_operand) and 64-bit (i64/u64 via shared int64_comparison helper factored out of v_cmp_*_{i64,u64}), enforcing VGPR-pair vsrc1 for 64-bit and keeping _e64, SDWA, f16, f64, and class rejected.
  • tests/pixel_aot_check.py & tests/form_coverage_check.py: adds 16-bit/64-bit v_cmpx draw/mismatch controls, equivalence and rejection controls, and updates VOPC v_cmpx form coverage from 32 to 60 forms (+28). docs/experiments.md documents the expanded scope and remaining ISA-text hypothesis cleanly.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036125194 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1335#pullrequestreview-6036125194). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:45:43Z. **Review:** COMMENTED --- Reviewed at commit `9d0e43ee5bc80be1c96db933fa42bcde2ca8f12b`. ### Linux Checks - `git diff --check origin/main...HEAD`: passed (no whitespace/conflict-marker issues). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (`Checked 16 Markdown files and 294 links.`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (`Checked 1108 tracked source, script and build/CI files: no bidirectional controls.`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py`: passed (`Ran 138 tests ... OK (skipped=18)`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: passed (`form coverage checks passed`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py` (pure-Python mode): passed (exit 0). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: failed in unrelated existing `check_f16_cvt_int16_binary` (`v_cvt_f16_i16_e32 v1, 0xfff0`, LLVM-19 vs LLVM-15 encoding/spelling expectation). ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Windows Python checks**: `tests/form_coverage_check.py` passed (`39.26s`). - **Debug (`--preset dev`)**: - Build (`offscreen_check`): `36.02s` (configure `1.53s`) - `ctest --preset dev -R '^(pixel_aot_cmpx_regions_warp|pixel_aot_comparisons_warp|pixel_aot_cmp64_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **3/3 passed** (`pixel_aot_cmp64_warp` `3.34s`, `pixel_aot_cmpx_regions_warp` `3.64s`, `pixel_aot_comparisons_warp` `7.49s`) - **Release `/O2` (`--preset release`)**: - Build (`offscreen_check`): `52.12s` (configure `1.58s`) - `ctest --preset release -R '^(pixel_aot_cmpx_regions_warp|pixel_aot_comparisons_warp|pixel_aot_cmp64_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **3/3 passed** (`pixel_aot_cmp64_warp` `3.08s`, `pixel_aot_cmpx_regions_warp` `3.47s`, `pixel_aot_comparisons_warp` `7.30s`) ### Code Review Notes - `tools/pixel_aot.py`: cleanly extends VOPC `_e32` `v_cmpx` region openers to 16-bit (`eq`/`ne`/`lt`/`le`/`gt`/`ge` on `i16`/`u16` via `int16_operand`) and 64-bit (`i64`/`u64` via shared `int64_comparison` helper factored out of `v_cmp_*_{i64,u64}`), enforcing VGPR-pair `vsrc1` for 64-bit and keeping `_e64`, SDWA, `f16`, `f64`, and `class` rejected. - `tests/pixel_aot_check.py` & `tests/form_coverage_check.py`: adds 16-bit/64-bit `v_cmpx` draw/mismatch controls, equivalence and rejection controls, and updates VOPC `v_cmpx` form coverage from 32 to 60 forms (+28). `docs/experiments.md` documents the expanded scope and remaining ISA-text hypothesis cleanly.
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!1328
No description provided.