shader: lower vector shifts and subtracts in the compute store profile #1111

Merged
tedin7 merged 2 commits from upstream-pr/1118 into main 2026-11-24 02:20:49 +00:00
tedin7 commented 2026-11-24 01:17:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:17:50Z.


Change

Lowers four more unsigned vector ALU operations in the compute store profile: v_lshlrev_b32_e32 on a known word that is not a dispatch index (a shifted index stays a byte offset), v_ashrrev_i32_e32 (arithmetic), v_sub_nc_u32_e32 and v_subrev_nc_u32_e32. Refs #721. Separate code from #1083 and #1090; it touches the same ALU table and regex, so one of them may need a rebase.

This change was AI-assisted.

Verification

  • python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: exit 0 (LLVM 19 locally; CI uses LLVM 15).
  • Same test on origin/main tools (the lowering reverted): fails with Unverified dispatch byte offset at the new fixture.
  • A new read_shift_sub fixture is added to the draw-guard-read Windows entry. I have no WARP adapter here, so the readback itself runs only in CI. Locally I evaluated the generated HLSL expression for 150 lanes and compared it with the independent CPU reference: 0 mismatches.

Evidence and follow-up

  • The readback compares the full 320 words with a CPU model written from the instruction definitions. Wrong references (logical right shift, shift by 16, no left shift, reversed sub, reversed subrev) must each fail at the first word where they differ; recompiled HLSL mutations must fail the readback.
  • The fixture is hand-written assembly assembled by llvm-mc; no game data. The docs in docs/experiments.md list the new operations and the controls.
  • New rejection controls: unknown VGPR source, unknown SGPR, destination past v255, an SGPR as the second VOP2 source, a register range and an output modifier.

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.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572393889 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1118). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:17:50Z. --- ## Change Lowers four more unsigned vector ALU operations in the compute store profile: `v_lshlrev_b32_e32` on a known word that is not a dispatch index (a shifted index stays a byte offset), `v_ashrrev_i32_e32` (arithmetic), `v_sub_nc_u32_e32` and `v_subrev_nc_u32_e32`. Refs #721. Separate code from #1083 and #1090; it touches the same ALU table and regex, so one of them may need a rebase. This change was AI-assisted. ## Verification - `python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: exit 0 (LLVM 19 locally; CI uses LLVM 15). - Same test on origin/main tools (the lowering reverted): fails with `Unverified dispatch byte offset` at the new fixture. - A new `read_shift_sub` fixture is added to the `draw-guard-read` Windows entry. I have no WARP adapter here, so the readback itself runs only in CI. Locally I evaluated the generated HLSL expression for 150 lanes and compared it with the independent CPU reference: 0 mismatches. ## Evidence and follow-up - The readback compares the full 320 words with a CPU model written from the instruction definitions. Wrong references (logical right shift, shift by 16, no left shift, reversed sub, reversed subrev) must each fail at the first word where they differ; recompiled HLSL mutations must fail the readback. - The fixture is hand-written assembly assembled by llvm-mc; no game data. The docs in docs/experiments.md list the new operations and the controls. - New rejection controls: unknown VGPR source, unknown SGPR, destination past v255, an SGPR as the second VOP2 source, a register range and an output modifier. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:46:25 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T01:18:00Z.


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-24T01:22:07.828002Z 4a2740d 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:7118962767 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1118#issuecomment-7118962767). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T01:18:00Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"4a2740d735b03603db1e48eff67f8b65c2aa79d5","has_any_findings":false,"has_unresolved_findings":false,"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-24T01:22:07.828002Z">2026-11-24T01:22:07.828002Z</relative-time> | `4a2740d` | 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:50:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:35:26Z.


AI-assisted. Merged origin/main to resolve conflicts in the compute store lowerer, its test and docs/experiments.md. Both sets of VOP2 operations are kept: the add, or, xor and max case from main and the shift and subtract case from this branch, each with its own CPU reference and negative controls. v_ashrrev_i32 moves from the rejected list to the supported list. tests/compute_store_check.py passes locally with LLVM 19.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119251795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1118#issuecomment-7119251795). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:35:26Z. --- AI-assisted. Merged origin/main to resolve conflicts in the compute store lowerer, its test and docs/experiments.md. Both sets of VOP2 operations are kept: the add, or, xor and max case from main and the shift and subtract case from this branch, each with its own CPU reference and negative controls. v_ashrrev_i32 moves from the rejected list to the supported list. tests/compute_store_check.py passes locally with LLVM 19.
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!1111
No description provided.