feat: keep wave-uniformity through pure integer VALU ops in gfx2hlsl #2714

Merged
tedin7 merged 5 commits from upstream-pr/2722 into main 2026-11-26 05:35:27 +00:00
tedin7 commented 2026-11-26 03:32:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:32:08Z.


Part of #1723

What this unblocks: v_readfirstlane_b32 of an integer-computed uniform VGPR past the entry block (the "requires a proven uniform source" refusal) in compute shaders.

What changed

  • UNIFORM_VALU now includes the pure 32-bit integer ops: add/sub/subrev, and/or/xor/not, lshl/lshr/ashr, mul_lo, mul_u32_u24, min/max (u32/i32).
  • A result computed only from uniform sources is uniform, so the existing past-entry recompute path (uniform_expr) can read it back.

Why it is correct

  • Each op reads only its own lane's sources (no carry-out, no lane id, no cross-lane read), so equal inputs give equal outputs in every lane.
  • The existing guards stay: no modifiers, every source uniform, known EXEC or a recomputable expression, join and lane-mask rules. The thread-id shift path of v_lshrrev_b32 is unchanged.

What stays refused

  • A source that is the thread id, a lane-mask scalar, or any per-lane value (negative controls in the test).
  • Loads past the entry block are not covered here.

Tests

Extends startup_compute_readfirstlane_check.py: a (s27 + s27) << 1 chain read with v_readfirstlane_b32 after a branch and a loop, WARP GPU readback vs the CPU reference, a dropped-read mutation control, and two refusal controls (thread-id source, lane-mask source). The new case fails on current main and passes with this change.

Verification

  • Linux: python3 -B tests/startup_compute_readfirstlane_check.py fails on main (refusal) and passes on this branch.
  • Linux: all 241 tests/startup_*check.py pass on this branch.
  • Win2025 (Windows Server 2025, MSVC 14.44 + D3D12 WARP) on head adb3b7d7: dev ^startup_compute_readfirstlane|^startup_gfx2hlsl 253/253 passed; dev and release ^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane 5/5 passed each (including the WARP readback of the integer chain).

Commands (run per preset dev and release):

cmake --build --preset <preset> --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check
ctest --preset <preset> -R '^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane' --no-tests=error -V

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6618899889 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:32:08Z. --- Part of #1723 What this unblocks: `v_readfirstlane_b32` of an integer-computed uniform VGPR past the entry block (the "requires a proven uniform source" refusal) in compute shaders. ## What changed - `UNIFORM_VALU` now includes the pure 32-bit integer ops: add/sub/subrev, and/or/xor/not, lshl/lshr/ashr, mul_lo, mul_u32_u24, min/max (u32/i32). - A result computed only from uniform sources is uniform, so the existing past-entry recompute path (`uniform_expr`) can read it back. ## Why it is correct - Each op reads only its own lane's sources (no carry-out, no lane id, no cross-lane read), so equal inputs give equal outputs in every lane. - The existing guards stay: no modifiers, every source uniform, known EXEC or a recomputable expression, join and lane-mask rules. The thread-id shift path of `v_lshrrev_b32` is unchanged. ## What stays refused - A source that is the thread id, a lane-mask scalar, or any per-lane value (negative controls in the test). - Loads past the entry block are not covered here. ## Tests Extends `startup_compute_readfirstlane_check.py`: a `(s27 + s27) << 1` chain read with `v_readfirstlane_b32` after a branch and a loop, WARP GPU readback vs the CPU reference, a dropped-read mutation control, and two refusal controls (thread-id source, lane-mask source). The new case fails on current main and passes with this change. ## Verification - Linux: `python3 -B tests/startup_compute_readfirstlane_check.py` fails on main (refusal) and passes on this branch. - Linux: all 241 `tests/startup_*check.py` pass on this branch. - Win2025 (Windows Server 2025, MSVC 14.44 + D3D12 WARP) on head adb3b7d7: dev `^startup_compute_readfirstlane|^startup_gfx2hlsl` 253/253 passed; dev and release `^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane` 5/5 passed each (including the WARP readback of the integer chain). Commands (run per preset `dev` and `release`): ``` cmake --build --preset <preset> --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check ctest --preset <preset> -R '^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane' --no-tests=error -V ``` AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 05:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1016363fd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068571651 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#pullrequestreview-6068571651). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T04:30:53Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `1016363fd9` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 05:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:10Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068645158 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#pullrequestreview-6068645158). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:42:10Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 05:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:13Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068645467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#pullrequestreview-6068645467). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:42:13Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 05:02:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:17:22Z.


@MasterDomino Independent Stage-2 gate review of head adb3b7d7: PASS, marked Ready.

  • Fail before, pass after: the new integer-chain case in tests/startup_compute_readfirstlane_check.py fails on origin/main and passes here; dropping v_add_nc_u32 from UNIFORM_VALU makes it fail.
  • The sibling check tests/startup_gfx2hlsl_readfirstlane_uniform_check.py failed on the first head (a shift of a constant-overwritten v0 was accepted). The update is right: the constant write reaches the shift on every path, so 200 >> 6 is the same in every lane. Overwriting v0 on one branch path only, with a lane value, with a lane-mask scalar, after adding a per-lane value, or with unknown EXEC are all still refused, and the real thread-id shift controls (groups of 65 and 128, v1, loaded or swapped v0) are unchanged.
  • Thread id, min, xor and lane-mask operands in the integer chain are refused.
  • Windows Server 2025, D3D12 WARP: dev 253/253; dev and release 5/5 each on the readfirstlane checks.

Commands executed:

python3 -B tests/startup_compute_readfirstlane_check.py
python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py
python3 -B tests/startup_gfx2hlsl_readfirstlane_recompute_check.py
x2w_pipe.py win2025 2722 --regex '^startup_compute_readfirstlane|^startup_gfx2hlsl'
x2w_pipe.py win2025 2722 --regex '^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane' --no-skip-build --force

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182463149 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#issuecomment-7182463149). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:17:22Z. --- @MasterDomino Independent Stage-2 gate review of head adb3b7d7: PASS, marked Ready. - Fail before, pass after: the new integer-chain case in `tests/startup_compute_readfirstlane_check.py` fails on `origin/main` and passes here; dropping `v_add_nc_u32` from `UNIFORM_VALU` makes it fail. - The sibling check `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py` failed on the first head (a shift of a constant-overwritten `v0` was accepted). The update is right: the constant write reaches the shift on every path, so `200 >> 6` is the same in every lane. Overwriting `v0` on one branch path only, with a lane value, with a lane-mask scalar, after adding a per-lane value, or with unknown EXEC are all still refused, and the real thread-id shift controls (groups of 65 and 128, `v1`, loaded or swapped `v0`) are unchanged. - Thread id, `min`, `xor` and lane-mask operands in the integer chain are refused. - Windows Server 2025, D3D12 WARP: dev 253/253; dev and release 5/5 each on the readfirstlane checks. Commands executed: ``` python3 -B tests/startup_compute_readfirstlane_check.py python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py python3 -B tests/startup_gfx2hlsl_readfirstlane_recompute_check.py x2w_pipe.py win2025 2722 --regex '^startup_compute_readfirstlane|^startup_gfx2hlsl' x2w_pipe.py win2025 2722 --regex '^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane' --no-skip-build --force ``` AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:17:28Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T04:30:55.885672Z 1016363 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182464740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#issuecomment-7182464740). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T04:17:28Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"1016363fd9ccfca8e11e32d658b6db513f9909a1","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T04:30:55.885672Z">2026-11-26T04:30:55.885672Z</relative-time> | `1016363` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-26 05:02:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.

Code review location: tools/startup/gfx2hlsl.py; line 919

@@ -912,6 +912,11 @@ def smem_mods(mods):
     'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4',
     'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32',
     'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32',
+    # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give
+    # equal results in every lane (no carry-out, no lane ID, no cross-lane read).
+    'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32',
+    'v_lshlrev_b32', 'v_lshrrev_b32', 'v_ashrrev_i32', 'v_mul_lo_u32', 'v_mul_u32_u24',
+    'v_min_u32', 'v_max_u32', 'v_min_i32', 'v_max_i32',

P1 Badge Document the expanded uniform integer capability

This extends a public translator capability by accepting previously refused integer-computed first-lane reads, but neither README.md nor docs/experiments.md is updated. The existing uniform-sources experiment entry omits the newly permitted operations and the added integer-chain/constant-shift readback controls. Update the relevant capability and experiment documentation with the supported/refused scope and reproduction/results; AGENTS.md explicitly requires a corresponding documentation update when a public capability changes.

AGENTS.md reference: AGENTS.md:L314-L315

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703907481 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#discussion_r4703907481). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T04:30:53Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 919 ~~~~diff @@ -912,6 +912,11 @@ def smem_mods(mods): 'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4', 'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32', 'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32', + # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give + # equal results in every lane (no carry-out, no lane ID, no cross-lane read). + 'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32', + 'v_lshlrev_b32', 'v_lshrrev_b32', 'v_ashrrev_i32', 'v_mul_lo_u32', 'v_mul_u32_u24', + 'v_min_u32', 'v_max_u32', 'v_min_i32', 'v_max_i32', ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the expanded uniform integer capability** This extends a public translator capability by accepting previously refused integer-computed first-lane reads, but neither `README.md` nor `docs/experiments.md` is updated. The existing uniform-sources experiment entry omits the newly permitted operations and the added integer-chain/constant-shift readback controls. Update the relevant capability and experiment documentation with the supported/refused scope and reproduction/results; `AGENTS.md` explicitly requires a corresponding documentation update when a public capability changes. AGENTS.md reference: [AGENTS.md:L314-L315](https://github.com/R0Y00/Xbox2Windows/blob/1016363fd9ccfca8e11e32d658b6db513f9909a1/AGENTS.md#L314-L315) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 05:02:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.

Code review location: tools/startup/gfx2hlsl.py; line 917

@@ -912,6 +912,11 @@ def smem_mods(mods):
     'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4',
     'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32',
     'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32',
+    # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give
+    # equal results in every lane (no carry-out, no lane ID, no cross-lane read).
+    'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32',

P2 Badge Bound expression growth for the newly uniform integer chains

For a uniform VGPR reused as both operands, these entries make Stage.one() substitute the entire previous uniform_expr twice, causing exponential growth. A Linux repro using a 300-byte compute fixture containing 30 v_add_nc_u32 v10, v10, v10 instructions translates with the parent allowlist but raises MemoryError with this allowlist under a 256 MiB address-space limit, even without a first-lane read of that chain. The expressions are built eagerly regardless of whether recomputation is needed, so tiny, previously translatable integer shaders can now exhaust gigabytes of RAM. Bound expression size or preserve shared subexpressions instead of duplicating their text.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703907488 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#discussion_r4703907488). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T04:30:53Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 917 ~~~~diff @@ -912,6 +912,11 @@ def smem_mods(mods): 'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4', 'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32', 'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32', + # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give + # equal results in every lane (no carry-out, no lane ID, no cross-lane read). + 'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32', ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Bound expression growth for the newly uniform integer chains** For a uniform VGPR reused as both operands, these entries make `Stage.one()` substitute the entire previous `uniform_expr` twice, causing exponential growth. A Linux repro using a 300-byte compute fixture containing 30 `v_add_nc_u32 v10, v10, v10` instructions translates with the parent allowlist but raises `MemoryError` with this allowlist under a 256 MiB address-space limit, even without a first-lane read of that chain. The expressions are built eagerly regardless of whether recomputation is needed, so tiny, previously translatable integer shaders can now exhaust gigabytes of RAM. Bound expression size or preserve shared subexpressions instead of duplicating their text. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 05:02:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:10Z.

Code review location: tools/startup/gfx2hlsl.py; line 919

@@ -912,6 +912,11 @@ def smem_mods(mods):
     'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4',
     'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32',
     'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32',
+    # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give
+    # equal results in every lane (no carry-out, no lane ID, no cross-lane read).
+    'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32',
+    'v_lshlrev_b32', 'v_lshrrev_b32', 'v_ashrrev_i32', 'v_mul_lo_u32', 'v_mul_u32_u24',
+    'v_min_u32', 'v_max_u32', 'v_min_i32', 'v_max_i32',

Docs added in 2a6265c58: docs/experiments.md (section "Startup translator: uniform sources of v_readfirstlane_b32") now lists the integer ops, the refused sources, the expression limit and the GPU readback controls (dropped-int-read, dropped-const-shift).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703969359 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#discussion_r4703969359). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:42:10Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 919 ~~~~diff @@ -912,6 +912,11 @@ def smem_mods(mods): 'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4', 'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32', 'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32', + # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give + # equal results in every lane (no carry-out, no lane ID, no cross-lane read). + 'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32', + 'v_lshlrev_b32', 'v_lshrrev_b32', 'v_ashrrev_i32', 'v_mul_lo_u32', 'v_mul_u32_u24', + 'v_min_u32', 'v_max_u32', 'v_min_i32', 'v_max_i32', ~~~~ --- Docs added in 2a6265c58: `docs/experiments.md` (section "Startup translator: uniform sources of v_readfirstlane_b32") now lists the integer ops, the refused sources, the expression limit and the GPU readback controls (`dropped-int-read`, `dropped-const-shift`). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 05:02:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:13Z.

Code review location: tools/startup/gfx2hlsl.py; line 917

@@ -912,6 +912,11 @@ def smem_mods(mods):
     'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4',
     'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32',
     'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32',
+    # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give
+    # equal results in every lane (no carry-out, no lane ID, no cross-lane read).
+    'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32',

Fixed in 2a6265c58: the recompute text of a VGPR is kept only up to UNIFORM_EXPR_LIMIT (4096 chars); past it the VGPR has no recomputable expression (an entry-block read still copies the VGPR). New check in tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 22 doublings (v7 = v7 + v7) keep a bounded expression; without the fix the expression is 37,748,729 chars. Win2025 dev+release --regex readfirstlane: 5/5 passed.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703969632 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#discussion_r4703969632). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:42:13Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 917 ~~~~diff @@ -912,6 +912,11 @@ def smem_mods(mods): 'v_cvt_u32_f32', 'v_cvt_i32_f32', 'v_cvt_f32_u32', 'v_cvt_f32_ubyte0', 'v_cvt_off_f32_i4', 'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32', 'v_mul_f32', 'v_fma_f32', 'v_fmaak_f32', 'v_rcp_f32', 'v_med3_f32', 'v_mov_b32', + # Pure 32-bit integer ALU: each lane computes the result from its own sources only, so equal sources give + # equal results in every lane (no carry-out, no lane ID, no cross-lane read). + 'v_add_nc_u32', 'v_sub_nc_u32', 'v_subrev_nc_u32', 'v_and_b32', 'v_or_b32', 'v_xor_b32', 'v_not_b32', ~~~~ --- Fixed in 2a6265c58: the recompute text of a VGPR is kept only up to `UNIFORM_EXPR_LIMIT` (4096 chars); past it the VGPR has no recomputable expression (an entry-block read still copies the VGPR). New check in `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py`: 22 doublings (`v7 = v7 + v7`) keep a bounded expression; without the fix the expression is 37,748,729 chars. Win2025 dev+release `--regex readfirstlane`: 5/5 passed. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 06:01:55 +00:00
MasterDomino commented 2026-11-26 06:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T05:35:23Z.

Review: APPROVED


Approving 2a6265c5 (8 commits behind main, merges cleanly).

The new ops. The added ops are lane-local and table-lowered, with shift counts masked. Every existing guard still applies to them:

  • every source must be uniform (no thread id, lane-mask scalar, vcc or exec);
  • no modifiers;
  • DPP and SDWA spellings never match the allowlist;
  • entry-block proofs need a known EXEC;
  • past the entry block, the read recomputes a pure scalar expression, which is dropped on any SGPR or EXEC write it reads;
  • proofs are cleared at every branch target.

The thread-id shift path is unchanged, and turning "v0 overwritten by a constant" from a refusal into an accepted case is correct.

No shader-cache revision is needed:

  • the new proofs reach only reads and off stores that were refused before;
  • a waterfall head sits at a branch target, where proofs are cleared;
  • the expression limit can only turn a pathological translation into a refusal.

Environment: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818; debug layer on, 0 errors; dev preset.

Runs: ctest --preset dev --no-tests=error -R '^startup_compute_readfirstlane|^startup_gfx2hlsl': 260 passed, 0 skipped, 1 failed. The failure is startup_gfx2hlsl_fma_mix_dispatch_hardware, which fails the same way on main on this adapter (#2746), so it's unrelated. A trial merge with main passed the 114 non-GPU checks.

Mutants, run against the five readfirstlane tests:

  • removing v_add_nc_u32 fails startup_compute_readfirstlane and the uniform check;
  • lifting the expression limit fails the bounded doubling check;
  • adding v_mbcnt_lo_u32_b32 or v_cndmask_b32 to the allowlist survives.

Optional follow-up: a refusal control for a lane-dependent op (for example v_mbcnt_lo_u32_b32 v7, -1, 0, then v_readfirstlane_b32 s9, v7), so a later allowlist edit can't slip one in. Nit: UNIFORM_EXPR_LIMIT now separates the RUN_TIME_SYMBOLS comment from its constant.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069041704 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2722#pullrequestreview-6069041704). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T05:35:23Z. **Review:** APPROVED --- Approving `2a6265c5` (8 commits behind `main`, merges cleanly). **The new ops.** The added ops are lane-local and table-lowered, with shift counts masked. Every existing guard still applies to them: - every source must be uniform (no thread id, lane-mask scalar, `vcc` or `exec`); - no modifiers; - DPP and SDWA spellings never match the allowlist; - entry-block proofs need a known EXEC; - past the entry block, the read recomputes a pure scalar expression, which is dropped on any SGPR or EXEC write it reads; - proofs are cleared at every branch target. The thread-id shift path is unchanged, and turning "v0 overwritten by a constant" from a refusal into an accepted case is correct. **No shader-cache revision is needed:** - the new proofs reach only reads and `off` stores that were refused before; - a waterfall head sits at a branch target, where proofs are cleared; - the expression limit can only turn a pathological translation into a refusal. Environment: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818; debug layer on, 0 errors; dev preset. **Runs:** `ctest --preset dev --no-tests=error -R '^startup_compute_readfirstlane|^startup_gfx2hlsl'`: 260 passed, 0 skipped, 1 failed. The failure is `startup_gfx2hlsl_fma_mix_dispatch_hardware`, which fails the same way on `main` on this adapter (#2746), so it's unrelated. A trial merge with `main` passed the 114 non-GPU checks. **Mutants**, run against the five readfirstlane tests: - removing `v_add_nc_u32` fails `startup_compute_readfirstlane` and the uniform check; - lifting the expression limit fails the bounded doubling check; - adding `v_mbcnt_lo_u32_b32` or `v_cndmask_b32` to the allowlist survives. **Optional follow-up:** a refusal control for a lane-dependent op (for example `v_mbcnt_lo_u32_b32 v7, -1, 0`, then `v_readfirstlane_b32 s9, v7`), so a later allowlist edit can't slip one in. Nit: `UNIFORM_EXPR_LIMIT` now separates the `RUN_TIME_SYMBOLS` comment from its constant. 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!2714
No description provided.