startup: lower s_cselect_b32 into vcc_lo and exec_lo in gfx2hlsl #2113

Merged
denn0x merged 2 commits from upstream-pr/2121 into main 2026-11-25 01:25:20 +00:00
denn0x commented 2026-11-25 00:53:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:53:44Z.


Part of #1723

In wave32, vcc_lo and exec_lo hold the whole lane mask, and the generic scalar path in tools/startup/gfx2hlsl.py already writes them as vcc and exec. s_cselect_b32 goes through a separate select path that assumed an SGPR destination, so s_cselect_b32 vcc_lo, -1, 0 stopped the translation with a TypeError instead of a lowering or an Unsupported refusal.

Now:

  • vcc_lo and exec_lo get the lane's bit of the selected word; an exec_lo write clears exec_known.
  • SGPR and m0 destinations are lowered as before.
  • Any other destination, such as the null SGPR, is refused with an Unsupported message.

New test tests/startup_gfx2hlsl_cselect_mask_check.py, registered as startup_gfx2hlsl_cselect_mask_controls in CMakeLists.txt, AGENTS.md and the Python job, and described in docs/experiments.md. It decodes synthetic SOP2 words and evaluates the emitted select for both SCC values with the restricted evaluator of startup_gfx2hlsl_bit_alu_check.py. Negative control: the select with its & 1 removed gives a different vcc.

Verification (branch head 3dc861e2 on main 246a875d, Windows 11 Pro 10.0.26300, Python 3.13):

  • python -B tests/startup_gfx2hlsl_cselect_mask_check.py -> exit 0 (cselect mask: vcc_lo and exec_lo are the lane mask; SGPR and m0 unchanged; null refused). On main the same test fails with TypeError: 'NoneType' object is not subscriptable.
  • every tests/startup_gfx2hlsl_*_check.py, tests/startup_translator_check.py, tests/docs_links_check.py and tests/startup_tools_lint_check.py tools/startup -> 33 scripts, all exit 0.
  • git diff --check main..HEAD -> clean.
  • Not run: a DXC compile or a draw with this select; the check evaluates the emitted HLSL text only.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594597437 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2121). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:53:44Z. --- Part of #1723 In wave32, `vcc_lo` and `exec_lo` hold the whole lane mask, and the generic scalar path in `tools/startup/gfx2hlsl.py` already writes them as `vcc` and `exec`. `s_cselect_b32` goes through a separate select path that assumed an SGPR destination, so `s_cselect_b32 vcc_lo, -1, 0` stopped the translation with a `TypeError` instead of a lowering or an `Unsupported` refusal. Now: - `vcc_lo` and `exec_lo` get the lane's bit of the selected word; an `exec_lo` write clears `exec_known`. - SGPR and `m0` destinations are lowered as before. - Any other destination, such as the null SGPR, is refused with an `Unsupported` message. New test `tests/startup_gfx2hlsl_cselect_mask_check.py`, registered as `startup_gfx2hlsl_cselect_mask_controls` in `CMakeLists.txt`, `AGENTS.md` and the Python job, and described in `docs/experiments.md`. It decodes synthetic SOP2 words and evaluates the emitted select for both SCC values with the restricted evaluator of `startup_gfx2hlsl_bit_alu_check.py`. Negative control: the select with its `& 1` removed gives a different `vcc`. Verification (branch head `3dc861e2` on `main` `246a875d`, Windows 11 Pro 10.0.26300, Python 3.13): - `python -B tests/startup_gfx2hlsl_cselect_mask_check.py` -> exit 0 (`cselect mask: vcc_lo and exec_lo are the lane mask; SGPR and m0 unchanged; null refused`). On `main` the same test fails with `TypeError: 'NoneType' object is not subscriptable`. - every `tests/startup_gfx2hlsl_*_check.py`, `tests/startup_translator_check.py`, `tests/docs_links_check.py` and `tests/startup_tools_lint_check.py tools/startup` -> 33 scripts, all exit 0. - `git diff --check main..HEAD` -> clean. - Not run: a DXC compile or a draw with this select; the check evaluates the emitted HLSL text only. AI-assisted.
upstream-sync closed this pull request 2026-11-25 02:01:49 +00:00
R0Y00 commented 2026-11-25 02:02:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:21:41Z.


I merged main after #2116 and kept both this scalar select fixture and #2122's mask-overwrite fixture in Linux and CTest. The select, mask-overwrite, scalar arity and SOPK checks and docs links all pass together on Windows. The fixture evaluates emitted HLSL; this update does not add a GPU draw.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149467182 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2121#issuecomment-7149467182). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T01:21:41Z. --- I merged main after #2116 and kept both this scalar select fixture and #2122's mask-overwrite fixture in Linux and CTest. The select, mask-overwrite, scalar arity and SOPK checks and docs links all pass together on Windows. The fixture evaluates emitted HLSL; this update does not add a GPU draw.
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!2113
No description provided.