shader: lower u32 add, max, or and xor in the compute store profile #1076

Merged
tedin7 merged 3 commits from upstream-pr/1083 into main 2026-11-24 01:24:46 +00:00
tedin7 commented 2026-11-24 00:29:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T00:29:31Z.


Change

Adds four unsigned 32-bit VOP2 operations to the compute store profile's integer ALU subset: v_add_nc_u32_e32, v_max_u32_e32, v_or_b32_e32 and v_xor_b32_e32. They follow the existing v_min_u32_e32 and v_and_b32_e32 path: known-word sources, inline HLSL expression, no write to vcc. The docs table is updated, and the rejection controls that used v_max_u32 and v_or_b32 as examples now use v_max_i32 and v_xnor_b32.

Refs #721 (step 4, arithmetic subset).

Verification

  • python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passes with the change.
  • Same command with the new test and the unchanged tools/compute_store_aot.py from main: fails with Unsupported compute instruction: v_add_nc_u32_e32 v2, 7, v1.
  • python3 -B tests/rdna2_tools_check.py: 97 tests, OK (skipped=8).
  • Local runs used LLVM 19, not the LLVM 15 that CI uses. The four mnemonics and operand forms are ordinary VOP2 spellings.
  • tests/pixel_aot_check.py binary fails locally under LLVM 19 on v_cvt_f16_i16_e32; that file is untouched here.

Evidence and follow-up

New fixture read_vop2 chains add, or, xor and max and checks the exact lowered HLSL expression. This checks the translation text only. It is not a hardware or console result.

AI-assisted change.

Checklist

  • One behavior per PR
  • Docs updated
  • No game files, dumps or credentials
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6571796383 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:29:31Z. --- ## Change Adds four unsigned 32-bit VOP2 operations to the compute store profile's integer ALU subset: `v_add_nc_u32_e32`, `v_max_u32_e32`, `v_or_b32_e32` and `v_xor_b32_e32`. They follow the existing `v_min_u32_e32` and `v_and_b32_e32` path: known-word sources, inline HLSL expression, no write to vcc. The docs table is updated, and the rejection controls that used `v_max_u32` and `v_or_b32` as examples now use `v_max_i32` and `v_xnor_b32`. Refs #721 (step 4, arithmetic subset). ## Verification - `python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passes with the change. - Same command with the new test and the unchanged `tools/compute_store_aot.py` from main: fails with `Unsupported compute instruction: v_add_nc_u32_e32 v2, 7, v1`. - `python3 -B tests/rdna2_tools_check.py`: 97 tests, OK (skipped=8). - Local runs used LLVM 19, not the LLVM 15 that CI uses. The four mnemonics and operand forms are ordinary VOP2 spellings. - `tests/pixel_aot_check.py binary` fails locally under LLVM 19 on `v_cvt_f16_i16_e32`; that file is untouched here. ## Evidence and follow-up New fixture `read_vop2` chains add, or, xor and max and checks the exact lowered HLSL expression. This checks the translation text only. It is not a hardware or console result. AI-assisted change. ## Checklist - [x] One behavior per PR - [x] Docs updated - [x] No game files, dumps or credentials
upstream-sync closed this pull request 2026-11-24 06:46:13 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:46:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T00:33:13Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c7e4dd65f

ℹ️ 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:6031785246 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#pullrequestreview-6031785246). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T00:33:13Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5c7e4dd65f` <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>
R0Y00 commented 2026-11-24 06:46:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:50:55Z.

Review: CHANGES_REQUESTED


The LLVM 15 binary suite and the surrounding Windows compute fixture ran locally. I see why the indexed-copy oracle cannot check the new arithmetic. Please give this candidate a dedicated chained arithmetic readback with an independent CPU reference. Use inputs that show add wrap, high-bit XOR/OR and unsigned max choosing both operands, and a wrong max/signed or dropped-op control that changes a specific output word. This can reuse the existing 320-word case format.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6031935003 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#pullrequestreview-6031935003). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T00:50:55Z. **Review:** CHANGES_REQUESTED --- The LLVM 15 binary suite and the surrounding Windows compute fixture ran locally. I see why the indexed-copy oracle cannot check the new arithmetic. Please give this candidate a dedicated chained arithmetic readback with an independent CPU reference. Use inputs that show add wrap, high-bit XOR/OR and unsigned max choosing both operands, and a wrong max/signed or dropped-op control that changes a specific output word. This can reuse the existing 320-word case format.
R0Y00 commented 2026-11-24 06:46:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:05:13Z.

Review: APPROVED


The dedicated readback now runs in the guard-read entries. I reran both Windows Release entries on RTX 4060 Laptop and WARP at 4c3c11b1. All normal buffers matched and the independent alternative references caught the arithmetic and range errors while preserving the sentinel words. This clears my previous readback request.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032054350 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#pullrequestreview-6032054350). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:05:13Z. **Review:** APPROVED --- The dedicated readback now runs in the guard-read entries. I reran both Windows Release entries on RTX 4060 Laptop and WARP at 4c3c11b1. All normal buffers matched and the independent alternative references caught the arithmetic and range errors while preserving the sentinel words. This clears my previous readback request.
chatgpt-codex-connector[bot commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T00:29:47Z.


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-24T00:33:15.621324Z 5c7e4dd 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118128614 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#issuecomment-7118128614). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T00:29:47Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5c7e4dd65fb59a26f5458404ae169f1d8dd01257","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-24T00:33:15.621324Z">2026-11-24T00:33:15.621324Z</relative-time> | `5c7e4dd` | 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>
tedin7 commented 2026-11-24 06:49:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T00:56:53Z.


Added the dedicated readback (read_vop2 is back in the runtime list and has its own handler, not the indexed-copy oracle).

  • Chain per lane: p = lo16 * hi16 + gid; chain = 0x80000001 ^ (0x80000010 | (cap + p)); stored word = unsigned max(p, chain). The reference is plain Python integer arithmetic in tests/compute_store_check.py, independent of the lowering.
  • Inputs: cap 0xe0000000, so the add wraps (115 of 150 lanes), the max picks the product on 115 lanes and the chain on 35, and a signed max gives different words (the test asserts all of this before running).
  • Controls: references with a signed max, min for max, a dropped add, a dropped or, and a dropped xor each must fail at their first differing word; the same four edits on the translated HLSL must fail the readback.
  • Local: binary mode passes with LLVM 19. The draw itself needs the Windows jobs, which are running now.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118598982 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#issuecomment-7118598982). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:56:53Z. --- Added the dedicated readback (read_vop2 is back in the runtime list and has its own handler, not the indexed-copy oracle). - Chain per lane: p = lo16 * hi16 + gid; chain = 0x80000001 ^ (0x80000010 | (cap + p)); stored word = unsigned max(p, chain). The reference is plain Python integer arithmetic in tests/compute_store_check.py, independent of the lowering. - Inputs: cap 0xe0000000, so the add wraps (115 of 150 lanes), the max picks the product on 115 lanes and the chain on 35, and a signed max gives different words (the test asserts all of this before running). - Controls: references with a signed max, min for max, a dropped add, a dropped or, and a dropped xor each must fail at their first differing word; the same four edits on the translated HLSL must fail the readback. - Local: binary mode passes with LLVM 19. The draw itself needs the Windows jobs, which are running now. AI-assisted.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T00:33:13Z.

Code review location: tests/compute_store_check.py; line 781

@@ -768,10 +768,17 @@ def variant(lines, *changes):
     ("v_mad_u32_u24 v1, v2, v1, v0", "v_mul_lo_u32 v1, s0, v1"),
     ("v_min_u32_e32 v1, s0, v1", ""),
 )
+# The remaining unsigned VOP2 operations of the subset, chained so each result feeds the next.
+READ_VOP2 = variant(
+    READ_COMPUTE,
+    ("v_min_u32_e32 v1, s0, v1", "v_add_nc_u32_e32 v2, 7, v1\nv_or_b32_e32 v2, s0, v2\n"
+                                 "v_xor_b32_e32 v2, 0x80000001, v2\nv_max_u32_e32 v1, s0, v2"),
+)
 ALU_CASES = [
     ("read_compute", READ_COMPUTE, 32, READ_BINDING),
     ("read_mad24", READ_MAD24, 32, READ_BINDING),
     ("read_mul_lo", READ_MUL_LO, 32, READ_BINDING),
+    ("read_vop2", READ_VOP2, 32, READ_BINDING),

P1 Badge Add a matching runtime reference for the VOP2 fixture

When the Windows draw-guard-read mode consumes ALU_CASES, draw() routes read_vop2 to draw_read(). That handler uses read_words(), which expects an indexed copy (source_word(2 * gid + 1)), not the new arithmetic result. With the harness constants, lane 0 expects 0x8b06bba2 while the emitted expression yields 0xdffd2ae8, so the first nonempty dispatch fails the existing compute_store_aot_guard_read_* tests even when lowering is correct. Add a matching runtime reference and handler, or keep this text-only fixture separate from the runtime case list.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4673929265 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1083#discussion_r4673929265). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T00:33:13Z. **Code review location:** `tests/compute_store_check.py`; line 781 ~~~~diff @@ -768,10 +768,17 @@ def variant(lines, *changes): ("v_mad_u32_u24 v1, v2, v1, v0", "v_mul_lo_u32 v1, s0, v1"), ("v_min_u32_e32 v1, s0, v1", ""), ) +# The remaining unsigned VOP2 operations of the subset, chained so each result feeds the next. +READ_VOP2 = variant( + READ_COMPUTE, + ("v_min_u32_e32 v1, s0, v1", "v_add_nc_u32_e32 v2, 7, v1\nv_or_b32_e32 v2, s0, v2\n" + "v_xor_b32_e32 v2, 0x80000001, v2\nv_max_u32_e32 v1, s0, v2"), +) ALU_CASES = [ ("read_compute", READ_COMPUTE, 32, READ_BINDING), ("read_mad24", READ_MAD24, 32, READ_BINDING), ("read_mul_lo", READ_MUL_LO, 32, READ_BINDING), + ("read_vop2", READ_VOP2, 32, READ_BINDING), ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Add a matching runtime reference for the VOP2 fixture** When the Windows `draw-guard-read` mode consumes `ALU_CASES`, `draw()` routes `read_vop2` to `draw_read()`. That handler uses `read_words()`, which expects an indexed copy (`source_word(2 * gid + 1)`), not the new arithmetic result. With the harness constants, lane 0 expects `0x8b06bba2` while the emitted expression yields `0xdffd2ae8`, so the first nonempty dispatch fails the existing `compute_store_aot_guard_read_*` tests even when lowering is correct. Add a matching runtime reference and handler, or keep this text-only fixture separate from the runtime case list. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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!1076
No description provided.