shader: lower v_sub_co_ci_u32, v_subrev_co_ci_u32 and s_flbit_i32_b32 in gfx2hlsl (Part of #1723) #2041

Closed
github-bot wants to merge 2 commits from gh-pr/2041/head into gh-pr/2041/base
Owner

@⁠tedin7 on GitHub · 2026-11-24 23:32 UTC · original
tedin7:x2w-r21-scalar-twins-b → main · +239 −3 · 7 files · 2 commits · closed without merging

Part of #1723

What this unblocks: Run 21 census, the predicted RDNA2 twins v_sub_co_ci_u32, v_subrev_co_ci_u32 and s_flbit_i32_b32.

Branch: x2w-r21-scalar-twins-b (commit e64b04fa, local, not pushed).

Changes in tools/startup/gfx2hlsl.py:

  • v_sub_co_ci_u32: D = S0 - S1 - carry_in, borrow out S0 < S1 + carry_in, written to vcc or an SGPR mask (bit 0, one lane).
  • v_subrev_co_ci_u32: same with S0 and S1 swapped.
  • Both refuse modifiers, a wrong operand count, a non-VGPR destination and a carry-in SGPR that is not a known mask.
  • s_flbit_i32_b32: S0 == 0u ? 0xffffffffu : 31u - firstbithigh(S0), SCC unchanged. Word-only: lane masks are refused, as for s_pack_hh_b32_b16.

Verification:

  • python3 -I tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py -> PASS (new test, registered in CMakeLists.txt as startup_gfx2hlsl_sub_co_ci_flbit).
  • Same test against origin/main tools -> fails with Unsupported: v_sub_co_ci_u32.
  • python3 -I tests/startup_gfx2hlsl_sop2_complement_check.py -> PASS
  • python3 -I tests/startup_gfx2hlsl_vcvt_omod_check.py -> PASS
  • python3 -I tests/startup_gfx2hlsl_bit_alu_check.py -> all lines ok
  • Checked before starting: no v_sub_co_ci, v_subrev_co_ci or s_flbit in tools/startup/ on main.
  • Not run: Win2025 build and CTest (this host is Linux, Python tests only).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 23:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041) `tedin7:x2w-r21-scalar-twins-b` → `main` · +239 −3 · 7 files · 2 commits · closed without merging Part of #1723 What this unblocks: Run 21 census, the predicted RDNA2 twins `v_sub_co_ci_u32`, `v_subrev_co_ci_u32` and `s_flbit_i32_b32`. Branch: `x2w-r21-scalar-twins-b` (commit e64b04fa, local, not pushed). Changes in `tools/startup/gfx2hlsl.py`: - `v_sub_co_ci_u32`: `D = S0 - S1 - carry_in`, borrow out `S0 < S1 + carry_in`, written to vcc or an SGPR mask (bit 0, one lane). - `v_subrev_co_ci_u32`: same with S0 and S1 swapped. - Both refuse modifiers, a wrong operand count, a non-VGPR destination and a carry-in SGPR that is not a known mask. - `s_flbit_i32_b32`: `S0 == 0u ? 0xffffffffu : 31u - firstbithigh(S0)`, SCC unchanged. Word-only: lane masks are refused, as for `s_pack_hh_b32_b16`. Verification: - `python3 -I tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py` -> PASS (new test, registered in CMakeLists.txt as `startup_gfx2hlsl_sub_co_ci_flbit`). - Same test against `origin/main` tools -> fails with `Unsupported: v_sub_co_ci_u32`. - `python3 -I tests/startup_gfx2hlsl_sop2_complement_check.py` -> PASS - `python3 -I tests/startup_gfx2hlsl_vcvt_omod_check.py` -> PASS - `python3 -I tests/startup_gfx2hlsl_bit_alu_check.py` -> all lines ok - Checked before starting: no `v_sub_co_ci`, `v_subrev_co_ci` or `s_flbit` in `tools/startup/` on main. - Not run: Win2025 build and CTest (this host is Linux, Python tests only). AI-assisted; commands listed were executed locally.
Document the forms and refusal boundaries, and let the fetch definite-assignment check see the VGPR written by the borrow-chain block.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:51:40 +00:00
github-bot closed this pull request 2026-11-26 23:51:40 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:32 UTC · original · edited 2026-11-24 23:38 UTC

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-24T23:38:18.499370Z e64b04f PR opened
ℹ️ 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#issuecomment-7147518929) · edited 2026-11-24 23:38 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e64b04fa4b9f4023f1aa7a26891532b828e8b011","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-24T23:38:18.499370Z">2026-11-24T23:38:18.499370Z</relative-time> | `e64b04f` | PR opened | <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>
@ -2829,2 +2829,4 @@
add_test(NAME startup_gfx2hlsl_sopk_accum COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sopk_accum_check.py")
add_test(NAME startup_gfx2hlsl_sub_co_ci_flbit COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py")
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:38 UTC · original

P1 Badge Document the new startup translation capability

This adds three previously refused startup-translator instruction forms and a new reproduction test, but neither README.md nor docs/experiments.md is updated. AGENTS.md explicitly requires updating one of those documents when a public capability or reproduction command changes. Record the supported forms, refusal boundaries, and regression command, distinguishing the CPU-only verification from unmeasured Windows/GPU behavior.

AGENTS.md reference: AGENTS.md:L210-L211

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#discussion_r4688065451) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the new startup translation capability** This adds three previously refused startup-translator instruction forms and a new reproduction test, but neither `README.md` nor `docs/experiments.md` is updated. `AGENTS.md` explicitly requires updating one of those documents when a public capability or reproduction command changes. Record the supported forms, refusal boundaries, and regression command, distinguishing the CPU-only verification from unmeasured Windows/GPU behavior. AGENTS.md reference: [AGENTS.md:L210-L211](https://github.com/R0Y00/Xbox2Windows/blob/e64b04fa4b9f4023f1aa7a26891532b828e8b011/AGENTS.md#L210-L211) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -1784,0 +1822,4 @@
self.sym.pop(out_n, None)
self.masks.add(out_n)
store = 's%d = %s;' % (out_n, borrow)
self.emit('{ uint ca = %s, cb = %s, ci = %s & 1u; %sv%d = ca - cb - ci; %s }' % (a, b, borrow_in, guard, d, store))
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:38 UTC · original

P2 Badge Expose the VGPR write to the fetch definite-assignment check

For vertex shaders that start with the modeled fetch call, Pipeline.hlsl_vs() recognizes definitions only when an emitted line starts with vN =. This block-form line instead makes that scan count the destination as a read, so an unconditional subtraction into a fresh VGPR is incorrectly refused. Using the existing stream-fetch fixture, v_sub_co_ci_u32_e32 v12, vcc_lo, v4, v5, vcc_lo fails with vertex stage reads v12 even though both inputs are fetched; initializing v12 beforehand makes it translate. The reverse form fails identically. Update the definition tracking to recognize these writes while preserving the temporary snapshots needed for aliasing.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#discussion_r4688065461) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Expose the VGPR write to the fetch definite-assignment check** For vertex shaders that start with the modeled fetch call, `Pipeline.hlsl_vs()` recognizes definitions only when an emitted line starts with `vN =`. This block-form line instead makes that scan count the destination as a read, so an unconditional subtraction into a fresh VGPR is incorrectly refused. Using the existing stream-fetch fixture, `v_sub_co_ci_u32_e32 v12, vcc_lo, v4, v5, vcc_lo` fails with `vertex stage reads v12` even though both inputs are fetched; initializing `v12` beforehand makes it translate. The reverse form fails identically. Update the definition tracking to recognize these writes while preserving the temporary snapshots needed for aliasing. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -2829,2 +2829,4 @@
add_test(NAME startup_gfx2hlsl_sopk_accum COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sopk_accum_check.py")
add_test(NAME startup_gfx2hlsl_sub_co_ci_flbit COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py")
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 00:59 UTC · original

Fixed in 00544511 (rebased on current main, pending push to this branch). Docs: new section in docs/experiments.md, plus the check in AGENTS.md and the CI list. Definite-assignment: the borrow-chain block now counts as an unconditional write of its destination, with a translator case in tests/startup_stream_fetch_check.py. CPU-only; Windows/GPU behavior not measured.

AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py, tests/startup_stream_fetch_check.py, tests/startup_translator_check.py, tests/docs_links_check.py.

**@⁠tedin7** on GitHub · 2026-11-25 00:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#discussion_r4688743106) Fixed in 00544511 (rebased on current main, pending push to this branch). Docs: new section in docs/experiments.md, plus the check in AGENTS.md and the CI list. Definite-assignment: the borrow-chain block now counts as an unconditional write of its destination, with a translator case in tests/startup_stream_fetch_check.py. CPU-only; Windows/GPU behavior not measured. AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py, tests/startup_stream_fetch_check.py, tests/startup_translator_check.py, tests/docs_links_check.py.
@ -1784,0 +1822,4 @@
self.sym.pop(out_n, None)
self.masks.add(out_n)
store = 's%d = %s;' % (out_n, borrow)
self.emit('{ uint ca = %s, cb = %s, ci = %s & 1u; %sv%d = ca - cb - ci; %s }' % (a, b, borrow_in, guard, d, store))
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 00:59 UTC · original

Fixed in 00544511 (rebased on current main, pending push to this branch). Docs: new section in docs/experiments.md, plus the check in AGENTS.md and the CI list. Definite-assignment: the borrow-chain block now counts as an unconditional write of its destination, with a translator case in tests/startup_stream_fetch_check.py. CPU-only; Windows/GPU behavior not measured.

AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py, tests/startup_stream_fetch_check.py, tests/startup_translator_check.py, tests/docs_links_check.py.

**@⁠tedin7** on GitHub · 2026-11-25 00:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#discussion_r4688743365) Fixed in 00544511 (rebased on current main, pending push to this branch). Docs: new section in docs/experiments.md, plus the check in AGENTS.md and the CI list. Definite-assignment: the borrow-chain block now counts as an unconditional write of its destination, with a translator case in tests/startup_stream_fetch_check.py. CPU-only; Windows/GPU behavior not measured. AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sub_co_ci_flbit_check.py, tests/startup_stream_fetch_check.py, tests/startup_translator_check.py, tests/docs_links_check.py.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 13:50 UTC · original

Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.

We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#issuecomment-7164374142) Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:38 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e64b04fa4b

ℹ️ 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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2041#pullrequestreview-6049169051) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `e64b04fa4b` <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>

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.