shader: lower s_bitcmp0_b32 and s_bitcmp1_b32 in gfx2hlsl (Part of #1723) #2017

Merged
tedin7 merged 2 commits from upstream-pr/2024 into main 2026-11-24 23:50:40 +00:00
tedin7 commented 2026-11-24 23:26:50 +00:00 (Migrated from github.com)

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


Part of #1723

What this unblocks: Run 20 census #1 (128/114 pairs).

Lowers s_bitcmp1_b32 and s_bitcmp0_b32 (SOPC) in tools/startup/gfx2hlsl.py: SCC is set to the tested bit of S0, selected by S1[4:0], being 1 or 0. Nothing else is written.

Verification:

  • python3 -B tests/startup_gfx2hlsl_s_bitcmp_check.py on the branch: s_bitcmp: ok (216 cases: 6 words x 9 bit indexes x immediate and register forms x both ops, including indexes above 31).
  • Same test against origin/main sources: 216 mismatches (every case refused as Unsupported).
  • Existing checks still pass: startup_gfx2hlsl_swap_check.py, startup_gfx2hlsl_sdwa_check.py, startup_gfx2hlsl_operand_count_check.py, startup_gfx2hlsl_op_refusals_check.py.
  • Test registered in CMakeLists.txt as startup_gfx2hlsl_s_bitcmp.
  • Win2025 run: not executed here (Linux worker); the check is pure Python.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593491139 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2024). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:26:50Z. --- Part of #1723 What this unblocks: Run 20 census #1 (128/114 pairs). Lowers `s_bitcmp1_b32` and `s_bitcmp0_b32` (SOPC) in `tools/startup/gfx2hlsl.py`: SCC is set to the tested bit of S0, selected by S1[4:0], being 1 or 0. Nothing else is written. Verification: - `python3 -B tests/startup_gfx2hlsl_s_bitcmp_check.py` on the branch: `s_bitcmp: ok` (216 cases: 6 words x 9 bit indexes x immediate and register forms x both ops, including indexes above 31). - Same test against `origin/main` sources: `216 mismatches` (every case refused as `Unsupported`). - Existing checks still pass: `startup_gfx2hlsl_swap_check.py`, `startup_gfx2hlsl_sdwa_check.py`, `startup_gfx2hlsl_operand_count_check.py`, `startup_gfx2hlsl_op_refusals_check.py`. - Test registered in CMakeLists.txt as `startup_gfx2hlsl_s_bitcmp`. - Win2025 run: not executed here (Linux worker); the check is pure Python. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 00:04:58 +00:00
chatgpt-codex-connector[bot commented 2026-11-25 00:04:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:30:46Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ea4990831

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

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:27: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-24T23:30:48.543393Z 7ea4990 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:7147413005 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2024#issuecomment-7147413005). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:27:00Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"7ea4990831a4023f1afb13b33fc841a8788d21eb","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:30:48.543393Z">2026-11-24T23:30:48.543393Z</relative-time> | `7ea4990` | 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>
R0Y00 commented 2026-11-25 01:01:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:43:11Z.


I pushed a maintainer follow-up for the existing lane-mask finding. It reuses the integer word mask guard, checks direct EXEC/VCC and mask-tagged SGPRs in both operand positions, and documents the CPU-only test. On Windows the 216 scalar cases and 10 refusal controls passed, along with five existing translator checks and docs links. Full-mask SCC remains outside this patch.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147718106 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2024#issuecomment-7147718106). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T23:43:11Z. --- I pushed a maintainer follow-up for the existing lane-mask finding. It reuses the integer word mask guard, checks direct EXEC/VCC and mask-tagged SGPRs in both operand positions, and documents the CPU-only test. On Windows the 216 scalar cases and 10 refusal controls passed, along with five existing translator checks and docs links. Full-mask SCC remains outside this patch.
chatgpt-codex-connector[bot commented 2026-11-25 01:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:30:46Z.

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

@@ -1748,6 +1748,13 @@ def handler(self, ops, mods):
             return handler
         setattr(Stage, 'op_s_cmp_%s_%s' % (_name, _typ), _make())
         setattr(Stage, 'op_s_cmpk_%s_%s' % (_name, _typ), _make())
+# s_bitcmp1_b32 / s_bitcmp0_b32: SCC = S0[S1[4:0]] == 1 / == 0.
+for _bit in (0, 1):
+    def _make_bitcmp(bit=_bit):
+        def handler(self, ops, mods):
+            self.emit('scc = ((%s >> (%s & 31)) & 1u) == %du;' % (self.u(ops[0]), self.u(ops[1]), bit))

P1 Badge Reject wave-mask operands before lowering scalar bit tests

When a source is exec_lo, vcc_lo, or an SGPR tracked in self.masks, self.u() returns the current lane's projected 0/1 bit rather than the full 32-bit mask. For a fully active wave, s_bitcmp1_b32 exec_lo, 1 should set SCC, but the emitted expression evaluates to false because the generated exec starts at 1; copying EXEC to an SGPR has the same problem. A subsequent SCC branch or scalar select therefore takes the wrong path, whereas this program was previously refused. Reject lane-mask sources, as the existing word-level scalar handlers do, unless their full mask value can be modeled.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687989684 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2024#discussion_r4687989684). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:30:46Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1755 ~~~~diff @@ -1748,6 +1748,13 @@ def handler(self, ops, mods): return handler setattr(Stage, 'op_s_cmp_%s_%s' % (_name, _typ), _make()) setattr(Stage, 'op_s_cmpk_%s_%s' % (_name, _typ), _make()) +# s_bitcmp1_b32 / s_bitcmp0_b32: SCC = S0[S1[4:0]] == 1 / == 0. +for _bit in (0, 1): + def _make_bitcmp(bit=_bit): + def handler(self, ops, mods): + self.emit('scc = ((%s >> (%s & 31)) & 1u) == %du;' % (self.u(ops[0]), self.u(ops[1]), bit)) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Reject wave-mask operands before lowering scalar bit tests** When a source is `exec_lo`, `vcc_lo`, or an SGPR tracked in `self.masks`, `self.u()` returns the current lane's projected 0/1 bit rather than the full 32-bit mask. For a fully active wave, `s_bitcmp1_b32 exec_lo, 1` should set SCC, but the emitted expression evaluates to false because the generated `exec` starts at 1; copying EXEC to an SGPR has the same problem. A subsequent SCC branch or scalar select therefore takes the wrong path, whereas this program was previously refused. Reject lane-mask sources, as the existing word-level scalar handlers do, unless their full mask value can be modeled. 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!2017
No description provided.