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

Manually merged
github merged 2 commits from gh-pr/2121/head into gh-pr/2121/base 2026-11-26 23:58:11 +00:00
Owner

@⁠denn0x on GitHub · 2026-11-25 00:53 UTC · original
denn0x:startup/gfx2hlsl-cselect-lane-mask → main · +132 −4 · 6 files · 2 commits · merged 2026-11-25 01:25 UTC

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.

**@⁠denn0x** on GitHub · 2026-11-25 00:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2121) `denn0x:startup/gfx2hlsl-cselect-lane-mask` → `main` · +132 −4 · 6 files · 2 commits · merged 2026-11-25 01:25 UTC 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.
In wave32, vcc_lo and exec_lo hold the whole lane mask, and the generic
scalar path already writes them as vcc and exec. The select path assumed
an SGPR destination, so s_cselect_b32 vcc_lo, -1, 0 stopped the
translation with a TypeError. It now writes the lane's bit of the selected
word to vcc or exec (an exec_lo write clears exec_known), keeps the SGPR
and m0 destinations as before, and refuses any other destination with an
Unsupported message.

tests/startup_gfx2hlsl_cselect_mask_check.py decodes synthetic SOP2 words
and evaluates the emitted select for both SCC values, with an unreduced
select as the negative control. On the translator before this change it
fails with the TypeError.

Test: ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_cselect_mask_controls$' -V
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:58:09 +00:00
github manually merged commit 3c45e8e986 into gh-pr/2121/base 2026-11-26 23:58:11 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 01:21 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-25 01:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2121#issuecomment-7149467182) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.