shader: lower s_lshl1_add_u32 and s_lshl4_add_u32 in gfx2hlsl (Part of #1723) #2027

Manually merged
github merged 3 commits from gh-pr/2027/head into gh-pr/2027/base 2026-11-26 23:50:43 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 23:27 UTC · original
tedin7:x2w-r20-s-lshl-add → main · +164 −3 · 5 files · 3 commits · merged 2026-11-24 23:56 UTC

Part of #1723

What this unblocks: Run 20 census #16 (40/32 pairs).

Lowers s_lshl1_add_u32 .. s_lshl4_add_u32 in tools/startup/gfx2hlsl.py: D = (S0 << N) + S1, with SCC set to the carry out of the wide sum (bits shifted out of S0 count too). SCC is emitted before the destination write, so an in-place destination keeps the right sources. Lane-mask and descriptor-data operands are refused, as for the other SCC-from-word scalar ops.

Verification (commands executed locally):

  • python3 -B tests/startup_gfx2hlsl_s_lshl_add_check.py: all ok (4 ops x 10 operand forms x 1824 value pairs, plus mask refusals). Copied onto a detached origin/main tree it fails (rc=1) for all four ops.
  • Neighbouring checks still pass (rc=0): startup_gfx2hlsl_b64_shift_check.py, startup_gfx2hlsl_bit_alu_check.py, startup_gfx2hlsl_lane_alu.py, startup_gfx2hlsl_scalar_m0_check.py, startup_gfx2hlsl_sop2_complement_check.py.
  • Test registered in CMakeLists.txt as startup_gfx2hlsl_s_lshl_add.
  • Not run: Win2025 / CMake build (this was a local Linux Python run).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 23:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2027) `tedin7:x2w-r20-s-lshl-add` → `main` · +164 −3 · 5 files · 3 commits · merged 2026-11-24 23:56 UTC Part of #1723 What this unblocks: Run 20 census #16 (40/32 pairs). Lowers `s_lshl1_add_u32` .. `s_lshl4_add_u32` in `tools/startup/gfx2hlsl.py`: `D = (S0 << N) + S1`, with SCC set to the carry out of the wide sum (bits shifted out of S0 count too). SCC is emitted before the destination write, so an in-place destination keeps the right sources. Lane-mask and descriptor-data operands are refused, as for the other SCC-from-word scalar ops. Verification (commands executed locally): - `python3 -B tests/startup_gfx2hlsl_s_lshl_add_check.py`: all ok (4 ops x 10 operand forms x 1824 value pairs, plus mask refusals). Copied onto a detached `origin/main` tree it fails (rc=1) for all four ops. - Neighbouring checks still pass (rc=0): `startup_gfx2hlsl_b64_shift_check.py`, `startup_gfx2hlsl_bit_alu_check.py`, `startup_gfx2hlsl_lane_alu.py`, `startup_gfx2hlsl_scalar_m0_check.py`, `startup_gfx2hlsl_sop2_complement_check.py`. - Test registered in CMakeLists.txt as `startup_gfx2hlsl_s_lshl_add`. - Not run: Win2025 / CMake build (this was a local Linux Python run). AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:50:42 +00:00
github manually merged commit b80a3a5bf1 into gh-pr/2027/base 2026-11-26 23:50:43 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:27 UTC · original · edited 2026-11-24 23:31 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:31:32.255602Z d2f0e1d 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:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2027#issuecomment-7147417932) · edited 2026-11-24 23:31 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"d2f0e1df193500676b46f02e0dd29d7993c321d8","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:31:32.255602Z">2026-11-24T23:31:32.255602Z</relative-time> | `d2f0e1d` | 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>
@ -1884,1 +1891,4 @@
's_bfm_b32': ('(((1u << ({0} & 31)) - 1) << ({1} & 31))', None),
# s_lshlN_add_u32: low 32 bits of (S0 << N) + S1. SHIFT_ADD also supplies SCC for wide overflow.
's_lshl1_add_u32': ('({0} << 1) + {1}', None), 's_lshl2_add_u32': ('({0} << 2) + {1}', None),
's_lshl3_add_u32': ('({0} << 3) + {1}', None), 's_lshl4_add_u32': ('({0} << 4) + {1}', None),
Author
Owner

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

P2 Badge Guard unsupported destinations in the new shift-add lowering

For a shader containing s_lshl1_add_u32 null, 1, 1 (SDST 125), these entries now enter scalar(), whose destination write indexes reg_range('null') even though it returns None. Using the source-built pipeline fixture, translate_to(..., check=False) returns an unsupported result and writes .fail on the parent, but raises an uncaught TypeError here for all four opcodes. The request loop in main() does not catch that exception, so one such shader aborts the remaining cache translations. Handle the discard destination, or reject unsupported destination kinds with Unsupported before reaching the generic scalar writer.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2027#discussion_r4687996936) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Guard unsupported destinations in the new shift-add lowering** For a shader containing `s_lshl1_add_u32 null, 1, 1` (SDST 125), these entries now enter `scalar()`, whose destination write indexes `reg_range('null')` even though it returns `None`. Using the source-built pipeline fixture, `translate_to(..., check=False)` returns an unsupported result and writes `.fail` on the parent, but raises an uncaught `TypeError` here for all four opcodes. The request loop in `main()` does not catch that exception, so one such shader aborts the remaining cache translations. Handle the discard destination, or reject unsupported destination kinds with `Unsupported` before reaching the generic scalar writer. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 23:53 UTC · original

The maintainer update resolves the conflict with #2024 and rejects the discard destination for all four shift-add opcodes. Both new SCC producers now use the current uniformity-aware setter. Tests cover a varying source and the discard encoding, and the existing readfirstlane, complement/pack and bit-test cases passed after combining with main. The shift-and-add result and carry agree with the RDNA 2 SOP2 reference.

**@⁠R0Y00** on GitHub · 2026-11-24 23:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2027#issuecomment-7147916355) The maintainer update resolves the conflict with #2024 and rejects the discard destination for all four shift-add opcodes. Both new SCC producers now use the current uniformity-aware setter. Tests cover a varying source and the discard encoding, and the existing readfirstlane, complement/pack and bit-test cases passed after combining with main. The shift-and-add result and carry agree with the [RDNA 2 SOP2 reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf).
Author
Owner

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2f0e1df19

ℹ️ 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:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2027#pullrequestreview-6049091151) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `d2f0e1df19` <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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.