shader: fold s_ff1_i32 of exec outside guarded regions #1896

Merged
henriazz10 merged 1 commit from upstream-pr/1903 into main 2026-11-24 21:06:26 +00:00
henriazz10 commented 2026-11-24 20:43:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by henriazz10 on 2026-11-24T20:43:53Z.


Change

Refs #1543. This is the s_ff1_i32_b64 sD, exec and s_ff1_i32_b32 sD, exec_lo slice claimed in https://github.com/R0Y00/Xbox2Windows/issues/1543#issuecomment-7142817082. It follows the s_bcnt1_i32_b32 sN, exec_lo pattern and touches only tools/compute_store_aot.py, its test, CMakeLists.txt and docs/experiments.md.

  • Outside a guarded region, lane 0 of every wave is active for any group of at least 1 thread (and for wave32 the high half of exec is 0), so both s_ff1_i32_b64 sD, exec and s_ff1_i32_b32 sD, exec_lo fold to the known scalar word 0 for any group size, preserving SCC.
  • Refused, each with its own control:
    • the instruction inside a guarded region (s_and_saveexec_b32 up to the exec restore);
    • any other source (vcc, exec_hi, an SGPR, a literal, or a mismatched width);
    • an invalid or pending destination (s106, s12, or an SGPR pair s[4:5] on b64).

Verification

Commit 07c262a4, rebased onto f8f9bd7f (after #1904 merged; review nit fixed: blank line before the docs heading). The draws, controls() and the LLVM 15 round trip were re-run on 07c262a4. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC 1.8.2502.11, Python 3.12, debug layer enabled. offscreen_check was built from an earlier main; this PR does not change it.

python -B tests/compute_store_check.py draw-ff1-exec <dxc> <offscreen_check> warp
python -B tests/compute_store_check.py draw-ff1-exec <dxc> <offscreen_check> hardware
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
Backend Adapter / driver Result
WARP Microsoft Basic Render Driver 10.0.26100.9818 exit 0, compared_words=320 mismatches=0, debug_errors=0
hardware NVIDIA GeForce RTX 5080, 32.0.16.1692 exit 0, compared_words=320 mismatches=0, debug_errors=0

The LLVM 15 round trip in Docker (x2w-llvm15) exited 0:

docker run --rm -v "C:\Proyectos\Xbox2Windows\wt-ff1-exec:/src" x2w-llvm15 bash -c 'cp -r /src /w && cd /w && python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 /usr/lib/x86_64-linux-gnu/libLLVM-15.so.1; echo binary_exit=$?'

ff1_exec_binary() decodes the assembled fixture back to the same s_ff1_i32_b64 and s_ff1_i32_b32 lines and requires the same translation.

Negative control. With tools/compute_store_aot.py reverted to main, ff1_exec_controls() fails with ValueError: Unsupported compute instruction: s_ff1_i32_b64 s4, exec.

Evidence

The fixture is source-built in LLVM 15 spelling. It runs one group of 64 threads, storing (tid.x << 8) + s4 + s5 where s4 comes from s_ff1_i32_b64 s4, exec and s5 from s_ff1_i32_b32 s5, exec_lo. All 320 words are compared against a Python reference.

  • Translation controls. They check the exact HLSL line and all rejection conditions (guarded region, other/mismatched sources, invalid/pending/paired destinations).
  • Reference controls. Each must fail at its first differing word:
    • result taken as 1: word 0;
    • result taken as the lane index: word 1;
    • changed sentinel past the group: word 64.
  • Recompiled-HLSL control. Must fail on the device:
    • 1 in place of 0 for the folded s_ff1 result.

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 (docs/experiments.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6591035558 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1903). Originally posted by [henriazz10](https://github.com/henriazz10) on 2026-11-24T20:43:53Z. --- ## Change Refs #1543. This is the `s_ff1_i32_b64 sD, exec` and `s_ff1_i32_b32 sD, exec_lo` slice claimed in https://github.com/R0Y00/Xbox2Windows/issues/1543#issuecomment-7142817082. It follows the `s_bcnt1_i32_b32 sN, exec_lo` pattern and touches only `tools/compute_store_aot.py`, its test, `CMakeLists.txt` and `docs/experiments.md`. - Outside a guarded region, lane 0 of every wave is active for any group of at least 1 thread (and for wave32 the high half of `exec` is 0), so both `s_ff1_i32_b64 sD, exec` and `s_ff1_i32_b32 sD, exec_lo` fold to the known scalar word `0` for any group size, preserving `SCC`. - Refused, each with its own control: - the instruction inside a guarded region (`s_and_saveexec_b32` up to the `exec` restore); - any other source (`vcc`, `exec_hi`, an SGPR, a literal, or a mismatched width); - an invalid or pending destination (`s106`, `s12`, or an SGPR pair `s[4:5]` on `b64`). ## Verification Commit `07c262a4`, rebased onto `f8f9bd7f` (after #1904 merged; review nit fixed: blank line before the docs heading). The draws, `controls()` and the LLVM 15 round trip were re-run on `07c262a4`. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC 1.8.2502.11, Python 3.12, debug layer enabled. `offscreen_check` was built from an earlier `main`; this PR does not change it. ```powershell python -B tests/compute_store_check.py draw-ff1-exec <dxc> <offscreen_check> warp python -B tests/compute_store_check.py draw-ff1-exec <dxc> <offscreen_check> hardware python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` | Backend | Adapter / driver | Result | |---|---|---| | WARP | Microsoft Basic Render Driver 10.0.26100.9818 | exit 0, `compared_words=320 mismatches=0`, `debug_errors=0` | | hardware | NVIDIA GeForce RTX 5080, 32.0.16.1692 | exit 0, `compared_words=320 mismatches=0`, `debug_errors=0` | The LLVM 15 round trip in Docker (`x2w-llvm15`) exited 0: ```sh docker run --rm -v "C:\Proyectos\Xbox2Windows\wt-ff1-exec:/src" x2w-llvm15 bash -c 'cp -r /src /w && cd /w && python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 /usr/lib/x86_64-linux-gnu/libLLVM-15.so.1; echo binary_exit=$?' ``` `ff1_exec_binary()` decodes the assembled fixture back to the same `s_ff1_i32_b64` and `s_ff1_i32_b32` lines and requires the same translation. **Negative control.** With `tools/compute_store_aot.py` reverted to `main`, `ff1_exec_controls()` fails with `ValueError: Unsupported compute instruction: s_ff1_i32_b64 s4, exec`. ## Evidence The fixture is source-built in LLVM 15 spelling. It runs one group of 64 threads, storing `(tid.x << 8) + s4 + s5` where `s4` comes from `s_ff1_i32_b64 s4, exec` and `s5` from `s_ff1_i32_b32 s5, exec_lo`. All 320 words are compared against a Python reference. - **Translation controls.** They check the exact HLSL line and all rejection conditions (guarded region, other/mismatched sources, invalid/pending/paired destinations). - **Reference controls.** Each must fail at its first differing word: - result taken as `1`: word 0; - result taken as the lane index: word 1; - changed sentinel past the group: word 64. - **Recompiled-HLSL control.** Must fail on the device: - `1` in place of `0` for the folded `s_ff1` result. ## 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 (`docs/experiments.md`). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-24 21:01:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:52:39Z.

Review: COMMENTED


Review of head 1ade038375

Scope: C++ CMakeLists.txt (one new ctest entry), tools/compute_store_aot.py (s_ff1_i32 of exec folded to 0 outside guarded regions), tests/compute_store_check.py, docs/experiments.md. Tier D isolated shader ops. Author henriazz10.

Commands executed locally:

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0 (18 files, 376 links)
  • python3 tests/bidi_controls_check.py: rc=0 (1330 files)
  • python3 tests/compute_store_check.py (controls run at import, incl. ff1_exec_controls): passed
  • win2025 1903 --wait 900: Debug 66/66 passed (includes compute_store_aot_ff1_exec_warp); Release 66/66 passed

Mutation checks (logic in tools/compute_store_aot.py, reverted with git checkout -- .):

  1. folded result 0 -> 1: ff1_exec_controls assertion on the exact lowered line failed (AssertionError), rc=1
  2. removed the guarded-region rejection: the guarded control failed (rejects assertion on "First active lane inside guarded region"), rc=1

Findings: P1=0, P2=0. Nit: docs/experiments.md has no blank line before the new "#### First active lane of a full wave" heading.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047208459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1903#pullrequestreview-6047208459). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:52:39Z. **Review:** COMMENTED --- Review of head 1ade038375961ec28764454e6bb4ee6790583dbe Scope: C++ CMakeLists.txt (one new ctest entry), tools/compute_store_aot.py (s_ff1_i32 of exec folded to 0 outside guarded regions), tests/compute_store_check.py, docs/experiments.md. Tier D isolated shader ops. Author henriazz10. Commands executed locally: - git diff --check origin/main...HEAD: rc=0 - python3 tests/docs_links_check.py: rc=0 (18 files, 376 links) - python3 tests/bidi_controls_check.py: rc=0 (1330 files) - python3 tests/compute_store_check.py (controls run at import, incl. ff1_exec_controls): passed - win2025 1903 --wait 900: Debug 66/66 passed (includes compute_store_aot_ff1_exec_warp); Release 66/66 passed Mutation checks (logic in tools/compute_store_aot.py, reverted with git checkout -- .): 1. folded result 0 -> 1: ff1_exec_controls assertion on the exact lowered line failed (AssertionError), rc=1 2. removed the guarded-region rejection: the guarded control failed (rejects assertion on "First active lane inside guarded region"), rc=1 Findings: P1=0, P2=0. Nit: docs/experiments.md has no blank line before the new "#### First active lane of a full wave" heading. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 21:27:29 +00:00
tedin7 commented 2026-11-24 21:27:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:05:51Z.

Review: COMMENTED


Review of head 07c262a4f2

Scope: CMakeLists.txt (one new ctest entry), tools/compute_store_aot.py (s_ff1_i32 of exec folded to 0 outside guarded regions), tests/compute_store_check.py, docs/experiments.md. Tier D isolated shader ops. Author henriazz10. Retest after the author updated the PR; the earlier review of head 1ade0383 is superseded.

Commands executed locally:

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0 (18 files, 377 links)
  • python3 tests/bidi_controls_check.py: rc=0 (1338 files)
  • python3 tests/compute_store_check.py (controls run at import, incl. ff1_exec_controls): passed
  • x2w_pipe.py win2025 1903 --wait 900: Debug (preset dev) 67/67 passed, includes compute_store_aot_ff1_exec_warp; Release /O2 (preset release) 67/67 passed

Mutation checks (logic in tools/compute_store_aot.py, reverted with git checkout -- .):

  1. folded result 0 -> 1: ff1_exec_controls assertion on the exact lowered line failed (AssertionError), rc=1
  2. removed the guarded-region rejection: the guarded control failed (rc=1; lowering fell through to Unsupported compute instruction instead of the expected rejection message)

Findings: P1=0, P2=0.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047402564 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1903#pullrequestreview-6047402564). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:05:51Z. **Review:** COMMENTED --- Review of head 07c262a4f20be9de059237f79c7247fd675d9afc Scope: CMakeLists.txt (one new ctest entry), tools/compute_store_aot.py (s_ff1_i32 of exec folded to 0 outside guarded regions), tests/compute_store_check.py, docs/experiments.md. Tier D isolated shader ops. Author henriazz10. Retest after the author updated the PR; the earlier review of head 1ade0383 is superseded. Commands executed locally: - git diff --check origin/main...HEAD: rc=0 - python3 tests/docs_links_check.py: rc=0 (18 files, 377 links) - python3 tests/bidi_controls_check.py: rc=0 (1338 files) - python3 tests/compute_store_check.py (controls run at import, incl. ff1_exec_controls): passed - x2w_pipe.py win2025 1903 --wait 900: Debug (preset dev) 67/67 passed, includes compute_store_aot_ff1_exec_warp; Release /O2 (preset release) 67/67 passed Mutation checks (logic in tools/compute_store_aot.py, reverted with git checkout -- .): 1. folded result 0 -> 1: ff1_exec_controls assertion on the exact lowered line failed (AssertionError), rc=1 2. removed the guarded-region rejection: the guarded control failed (rc=1; lowering fell through to Unsupported compute instruction instead of the expected rejection message) Findings: P1=0, P2=0. AI-assisted; commands listed were executed locally.
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!1896
No description provided.