gfx2hlsl: read a joined mask ANDed with exec at an execz branch target #2458

Merged
NiiRoZz merged 7 commits from upstream-pr/2466 into main 2026-11-25 19:59:35 +00:00
NiiRoZz commented 2026-11-25 17:26:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T17:26:17Z.


What

tools/startup/gfx2hlsl.py refuses every read of a scalar register that holds, on some path into a branch
target, a symbol with no run-time value (numeric use of sN holding joined at a branch target). One read is
now accepted in vertex and pixel stages: s_and_b64 D, S, exec (either operand order) or
s_orn2_b64 D, S, exec, as the instruction at the target, when

  • every branch into the target is a forward s_cbranch_execz (no other branch kind, no backward branch, no
    calculated jump), and
  • the fall-through wrote S and left it a plain run-time number (no symbol at all).

Why

A common shape in compiled pixel programs:

s_cbranch_execz L          ; S still holds an old descriptor word or pointer
...
v_cmp_* S, ...             ; S = lane mask
L: s_and_b64 S, S, exec

In a set of 153 vertex/pixel requests measured on a local merge of open translator PRs, this was the first
refusal of 35: 34 with s_and_b64 (stale descriptor word, in 14 of them carried through an earlier join),
1 with s_orn2_b64 (stale table pointer). All 35 are pixel stages and all 35 meet the conditions above.

Argument

The translator models one lane; a lane mask is its bit 0, and s_cbranch_execz is emitted as a branch on
(exec & 1) == 0. The emitted statements are D = (S & exec) & 1 and D = (S | ~exec) & 1.

  • On the fall-through, the variable of S holds the register's value: the ordinary numeric read.
  • On a taken edge the lane's exec bit is 0 and nothing runs between the branch and the target, so bit 0 of
    the result is 0 (AND) or 1 (OR with the complement) whatever the variable of S holds. On hardware the
    lane's bit of S & exec is likewise 0 when the lane's exec bit is 0, whatever S holds.

Not proven here: that a lane whose exec bit is 0 may be treated as taking the branch while other lanes of
the wave fall through. That is the translator's standing one-lane model for every s_cbranch_execz in vertex
and pixel stages; this change adds no new assumption to it. SCC after the instruction is the lane's bit, as
for every other mask operation.

Change

  • Stage.translate: the set of targets entered only by forward s_cbranch_execz branches (empty for
    compute stages), and per target the joined registers whose fall-through value is a plain run-time number.
  • Stage.exec_absorbed_source + one line in Stage.scalar: the qualifying source is read as its variable;
    symbols are not changed, so a later read of the same register is still refused.
  • docs/experiments.md: three sentences under the join paragraph.

Still refused: any other read of a joined register; s_or_b64, s_andn2_b64, s_orn2_b64 with exec
first, s_and_b32; another branch kind or a second edge of another kind into the target; the same
instruction one instruction after the target; a constant (or any symbol) on the fall-through; compute stages.

Tests

tests/startup_gfx2hlsl_join_symbols_check.py (no arguments) gains check_exec_join():

  • the built words decode to the intended program (exact disassembly);
  • exact HLSL for the three accepted forms and for a destination other than the source;
  • exec as the destination, and the emitted right-hand sides evaluated with exec bit 0 over six words;
  • 12 refusal controls, each removing one condition, each naming the joined-register refusal;
  • with the lowering switched off in-process, the accepted forms are refused again.

Mutating each of the five conditions in the translator (branch kind, position, fall-through symbol,
operation, exec operand) makes the check fail.

python -B tests/startup_gfx2hlsl_join_symbols_check.py     both summary lines printed, exit 0
python -B tests/startup_translator_check.py                exit 0
python -B tests/startup_gfx2hlsl_*_check.py (62 files, no arguments)   all exit 0
python -B tests/startup_tools_lint_check.py, startup_uniform_lane_check.py,
          startup_compute_readfirstlane_check.py, docs_links_check.py    exit 0
git diff --check                                           clean

Not run: binary (no llvm-mc here; the new words are built from the SOP2/SOPP/VOP3 field layouts and are not
in the assembled SOURCES table), dispatch/control (no GPU run of the new fixture), ctest.

Measured

First refusal per request, 153 requests, same merged translator:

this refusal first
before 35
with this change 0

The 35 then stop at later refusals (34 at an operand form another open PR covers, 1 elsewhere); none
translates end to end from this change alone.

Limits

  • Pure-Python evidence only: emitted text and an argument, no GPU read-back of the new fixture.
  • No compute stages (they have their own execz handling), no s_and_b32/exec_lo form, no loop headers.
  • This measures translation, not rendering or title execution.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6609972482 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T17:26:17Z. --- ## What `tools/startup/gfx2hlsl.py` refuses every read of a scalar register that holds, on some path into a branch target, a symbol with no run-time value (`numeric use of sN holding joined at a branch target`). One read is now accepted in vertex and pixel stages: `s_and_b64 D, S, exec` (either operand order) or `s_orn2_b64 D, S, exec`, as the instruction at the target, when - every branch into the target is a forward `s_cbranch_execz` (no other branch kind, no backward branch, no calculated jump), and - the fall-through wrote S and left it a plain run-time number (no symbol at all). ## Why A common shape in compiled pixel programs: ``` s_cbranch_execz L ; S still holds an old descriptor word or pointer ... v_cmp_* S, ... ; S = lane mask L: s_and_b64 S, S, exec ``` In a set of 153 vertex/pixel requests measured on a local merge of open translator PRs, this was the first refusal of 35: 34 with `s_and_b64` (stale descriptor word, in 14 of them carried through an earlier join), 1 with `s_orn2_b64` (stale table pointer). All 35 are pixel stages and all 35 meet the conditions above. ## Argument The translator models one lane; a lane mask is its bit 0, and `s_cbranch_execz` is emitted as a branch on `(exec & 1) == 0`. The emitted statements are `D = (S & exec) & 1` and `D = (S | ~exec) & 1`. - On the fall-through, the variable of S holds the register's value: the ordinary numeric read. - On a taken edge the lane's exec bit is 0 and nothing runs between the branch and the target, so bit 0 of the result is 0 (AND) or 1 (OR with the complement) whatever the variable of S holds. On hardware the lane's bit of `S & exec` is likewise 0 when the lane's exec bit is 0, whatever S holds. Not proven here: that a lane whose exec bit is 0 may be treated as taking the branch while other lanes of the wave fall through. That is the translator's standing one-lane model for every `s_cbranch_execz` in vertex and pixel stages; this change adds no new assumption to it. SCC after the instruction is the lane's bit, as for every other mask operation. ## Change - `Stage.translate`: the set of targets entered only by forward `s_cbranch_execz` branches (empty for compute stages), and per target the joined registers whose fall-through value is a plain run-time number. - `Stage.exec_absorbed_source` + one line in `Stage.scalar`: the qualifying source is read as its variable; symbols are not changed, so a later read of the same register is still refused. - `docs/experiments.md`: three sentences under the join paragraph. Still refused: any other read of a joined register; `s_or_b64`, `s_andn2_b64`, `s_orn2_b64` with exec first, `s_and_b32`; another branch kind or a second edge of another kind into the target; the same instruction one instruction after the target; a constant (or any symbol) on the fall-through; compute stages. ## Tests `tests/startup_gfx2hlsl_join_symbols_check.py` (no arguments) gains `check_exec_join()`: - the built words decode to the intended program (exact disassembly); - exact HLSL for the three accepted forms and for a destination other than the source; - `exec` as the destination, and the emitted right-hand sides evaluated with exec bit 0 over six words; - 12 refusal controls, each removing one condition, each naming the joined-register refusal; - with the lowering switched off in-process, the accepted forms are refused again. Mutating each of the five conditions in the translator (branch kind, position, fall-through symbol, operation, exec operand) makes the check fail. ``` python -B tests/startup_gfx2hlsl_join_symbols_check.py both summary lines printed, exit 0 python -B tests/startup_translator_check.py exit 0 python -B tests/startup_gfx2hlsl_*_check.py (62 files, no arguments) all exit 0 python -B tests/startup_tools_lint_check.py, startup_uniform_lane_check.py, startup_compute_readfirstlane_check.py, docs_links_check.py exit 0 git diff --check clean ``` Not run: `binary` (no llvm-mc here; the new words are built from the SOP2/SOPP/VOP3 field layouts and are not in the assembled SOURCES table), `dispatch`/`control` (no GPU run of the new fixture), ctest. ## Measured First refusal per request, 153 requests, same merged translator: | | this refusal first | |---|---| | before | 35 | | with this change | 0 | The 35 then stop at later refusals (34 at an operand form another open PR covers, 1 elsewhere); none translates end to end from this change alone. ## Limits - Pure-Python evidence only: emitted text and an argument, no GPU read-back of the new fixture. - No compute stages (they have their own execz handling), no `s_and_b32`/`exec_lo` form, no loop headers. - This measures translation, not rendering or title execution. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ChazY11 commented 2026-11-25 18:01:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T17:41:34Z.


Five mutations: two caught, three survive, and one of them is the compute exclusion the comment calls out

Baseline on this branch: startup_gfx2hlsl_join_symbols_check.py exit 0 with both summary lines, and all 62 tests/startup_gfx2hlsl_*_check.py pass.

mutation of exec_join result
the kind == 'cs' exclusion removed (set() if False else …) survived
all(...) → any(...) for "every other path is s_cbranch_execz" caught
arriving[0][0][reg] is None → True (a folded value also qualifies) caught
the falls (fall-through wrote it) requirement dropped survived
self.sym.get(reg) == ('joined at a branch target',) → True survived

The first survivor is the documented exclusion

The comment says "Compute stages have their own execz handling and are left out", and the mutation that removes that exclusion is invisible to the fixture. I grepped rather than assumed: the fixture's own execz cases (lines 298–343) are the pixel-stage shape, and the two compute programs it mentions (CS_RELOAD, CS_UNPLACED, lines 23–27) are about descriptor reloads, not about this join. So nothing pins "compute is excluded", and a compute program that reaches this path would take the new code with no test noticing either way.

That is the one I would close, and cheaply: run(..., kind='cs') on the same program the pixel case uses, asserting the mask is not read there (the old refusal). One case, and it turns the exclusion into something the fixture states.

The other two survivors

  • falls — "the fall-through of a forward s_cbranch_execz" is what makes the stale value a plain run-time number; dropping the requirement widens the set to registers not written on the fall-through. I could not construct a program where that changes the output, and the fixture's at_target=False case may already be covering the shape; I am reporting it as unexercised rather than as a gap.
  • the 'joined at a branch target' marker — replacing it with True passes, which means the other conjuncts already restrict reg to joined registers in these fixtures, or the marker is redundant. If it is redundant it can go; if it is not, it wants a case.

What the two caught rows show

all → any is the classic weakening: a target with one execz edge and one scc1 edge would have its join read as if every path were execz. That is caught. And arriving[0][0][reg] is None → True means a constant-folded value now qualifies as the "stale run-time number" the transformation is allowed to absorb — also caught. Those are the two that decide whether the emitted mask is right, so the fixture is pinning the important half.

The twelve refusal controls and the "old behaviour still holds" line are the right shape for a change that relaxes a proof, which is what this is.

AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7169864305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#issuecomment-7169864305). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T17:41:34Z. --- ## Five mutations: two caught, three survive, and one of them is the compute exclusion the comment calls out Baseline on this branch: `startup_gfx2hlsl_join_symbols_check.py` exit 0 with both summary lines, and all 62 `tests/startup_gfx2hlsl_*_check.py` pass. | mutation of `exec_join` | result | |---|---| | the `kind == 'cs'` exclusion removed (`set() if False else …`) | survived | | `all(...)` → `any(...)` for "every other path is `s_cbranch_execz`" | **caught** | | `arriving[0][0][reg] is None` → `True` (a folded value also qualifies) | **caught** | | the `falls` (fall-through wrote it) requirement dropped | survived | | `self.sym.get(reg) == ('joined at a branch target',)` → `True` | survived | ### The first survivor is the documented exclusion The comment says "Compute stages have their own execz handling and are left out", and the mutation that removes that exclusion is invisible to the fixture. I grepped rather than assumed: the fixture's own `execz` cases (lines 298–343) are the pixel-stage shape, and the two compute programs it mentions (`CS_RELOAD`, `CS_UNPLACED`, lines 23–27) are about descriptor reloads, not about this join. So nothing pins "compute is excluded", and a compute program that reaches this path would take the new code with no test noticing either way. That is the one I would close, and cheaply: `run(..., kind='cs')` on the same program the pixel case uses, asserting the mask is **not** read there (the old refusal). One case, and it turns the exclusion into something the fixture states. ### The other two survivors - **`falls`** — "the fall-through of a forward `s_cbranch_execz`" is what makes the stale value a plain run-time number; dropping the requirement widens the set to registers not written on the fall-through. I could not construct a program where that changes the output, and the fixture's `at_target=False` case may already be covering the shape; I am reporting it as unexercised rather than as a gap. - **the `'joined at a branch target'` marker** — replacing it with `True` passes, which means the other conjuncts already restrict `reg` to joined registers in these fixtures, or the marker is redundant. If it is redundant it can go; if it is not, it wants a case. ### What the two caught rows show `all` → `any` is the classic weakening: a target with one `execz` edge and one `scc1` edge would have its join read as if every path were execz. That is caught. And `arriving[0][0][reg] is None` → `True` means a **constant-folded** value now qualifies as the "stale run-time number" the transformation is allowed to absorb — also caught. Those are the two that decide whether the emitted mask is right, so the fixture is pinning the important half. The twelve refusal controls and the "old behaviour still holds" line are the right shape for a change that relaxes a proof, which is what this is. AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
MasterDomino commented 2026-11-25 19:03:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T18:29:59Z.

Review: COMMENTED


Review of head baafda83. I checked it at that commit and merged with current main (6706077b, clean).

The argument holds. On every taken s_cbranch_execz edge into the target, the lane's exec bit is 0 and nothing runs between the branch and the target. So bit 0 of S & exec is 0, and bit 0 of S | ~exec is 1, whatever the variable of S holds. s_orn2_b64 is correctly limited to S as src0. No cache revision bump is needed, because the change only accepts requests that were refused before.

  • Checks: startup_gfx2hlsl_join_symbols_check.py and the neighbouring handler arity, operand count, saveexec, mask overwrite, readfirstlane and loop constants checks pass, at the head and merged with main.

One request before merge. Two of the conditions the description states are not pinned by the fixture. With these mutants of tools/startup/gfx2hlsl.py, applied one at a time and then reverted:

mutant join_symbols_check
"forward only" dropped (all(pc < t and …) becomes all(names[pc] == 's_cbranch_execz' …)) passes: no case has a backward s_cbranch_execz into the target
compute exclusion removed (@ChazY11's run above) passes
any branch kind (pc < t only) fails, as it should
s_orn2_b64 with exec as src0 fails
"only the instruction at the target" dropped fails
fall-through value with a symbol allowed fails

What would resolve it: two refusal cases in tests/startup_gfx2hlsl_join_symbols_check.py, each asserting the old numeric use of sN holding joined at a branch target refusal:

  1. the pixel program you already use, with the s_cbranch_execz into L placed after L (a backward edge);
  2. the same program translated as a compute stage (kind='cs'), as @ChazY11 suggests.

Both conditions are stated in the description, so with these cases a later change can't drop either one silently. Once they're in and CI is green, I'll merge.

AI-assisted; commands listed were executed locally (Windows 11 build 26300, Python 3.13).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062906529 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#pullrequestreview-6062906529). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T18:29:59Z. **Review:** COMMENTED --- Review of head `baafda83`. I checked it at that commit and merged with current `main` (`6706077b`, clean). **The argument holds.** On every taken `s_cbranch_execz` edge into the target, the lane's exec bit is 0 and nothing runs between the branch and the target. So bit 0 of `S & exec` is 0, and bit 0 of `S | ~exec` is 1, whatever the variable of S holds. `s_orn2_b64` is correctly limited to S as `src0`. No cache revision bump is needed, because the change only accepts requests that were refused before. - **Checks:** `startup_gfx2hlsl_join_symbols_check.py` and the neighbouring handler arity, operand count, saveexec, mask overwrite, readfirstlane and loop constants checks pass, at the head and merged with `main`. **One request before merge.** Two of the conditions the description states are not pinned by the fixture. With these mutants of `tools/startup/gfx2hlsl.py`, applied one at a time and then reverted: | mutant | `join_symbols_check` | |---|---| | "forward only" dropped (`all(pc < t and …)` becomes `all(names[pc] == 's_cbranch_execz' …)`) | **passes**: no case has a backward `s_cbranch_execz` into the target | | compute exclusion removed (@ChazY11's run above) | **passes** | | `any` branch kind (`pc < t` only) | fails, as it should | | `s_orn2_b64` with exec as `src0` | fails | | "only the instruction at the target" dropped | fails | | fall-through value with a symbol allowed | fails | **What would resolve it:** two refusal cases in `tests/startup_gfx2hlsl_join_symbols_check.py`, each asserting the old `numeric use of sN holding joined at a branch target` refusal: 1. the pixel program you already use, with the `s_cbranch_execz` into `L` placed **after** `L` (a backward edge); 2. the same program translated as a compute stage (`kind='cs'`), as @ChazY11 suggests. Both conditions are stated in the description, so with these cases a later change can't drop either one silently. Once they're in and CI is green, I'll merge. AI-assisted; commands listed were executed locally (Windows 11 build 26300, Python 3.13).
upstream-sync closed this pull request 2026-11-25 20:04:19 +00:00
tedin7 commented 2026-11-25 20:04:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:24:20Z.

Review: COMMENTED


Review of head d5658cdd (current head, checked against origin/main).

Findings:

  1. tools/startup/gfx2hlsl.py (new execz_targets, the kind == 'cs' exclusion): removing the exclusion (set() if False else {...}) leaves tests/startup_gfx2hlsl_join_symbols_check.py green. The compute exclusion the comment documents has no test, which matches the earlier mutation report in this thread. Add a case with a cs stage and the same execz shape that must still be refused.
  2. Same file, the falls and off in execz_targets condition: dropping falls also survives. No test has a target entered only by taken execz edges with no fall-through write. Add that refusal control.
  3. The self.sym.get(reg) == ('joined at a branch target',) check in the new exec_zero_join set can be replaced by True without any test failing. Either add a case where the register is not in the joined state, or drop the check if it is redundant with the other conditions.
  4. The other mutations are caught: s_orn2_b64 removed from the accepted forms, and the exec operand check removed.
  5. Lowering emits (exec & s16) & 1 and (s16 | ~exec) & 1. The reasoning in the docstring is sound for a one-lane model (a taken execz edge means exec bit 0 is 0). The change is an operand-reading rule, not new arithmetic, so I did not ask for a new WARP readback, but the test does compare the generated HLSL, not GPU output. Please say whether a readback is wanted here.

Not a blocker on its own, but I would fix 1 and 2 before merge: these are the guards that keep compute stages and fall-through-less targets refused.

Commands run locally:

  • python3 tests/startup_gfx2hlsl_join_symbols_check.py : exit 0, both summary lines
  • git diff --check origin/main...HEAD : clean
  • 5 manual mutations of gfx2hlsl.py (cs exclusion, falls, sym check, orn2, exec operand): 3 survived (items 1-3), 2 caught; tree restored with git checkout -- .

No Win2025 run and no game run were done by this review.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063660951 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#pullrequestreview-6063660951). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:24:20Z. **Review:** COMMENTED --- Review of head d5658cdd (current head, checked against origin/main). Findings: 1. `tools/startup/gfx2hlsl.py` (new `execz_targets`, the `kind == 'cs'` exclusion): removing the exclusion (`set() if False else {...}`) leaves `tests/startup_gfx2hlsl_join_symbols_check.py` green. The compute exclusion the comment documents has no test, which matches the earlier mutation report in this thread. Add a case with a `cs` stage and the same execz shape that must still be refused. 2. Same file, the `falls and off in execz_targets` condition: dropping `falls` also survives. No test has a target entered only by taken execz edges with no fall-through write. Add that refusal control. 3. The `self.sym.get(reg) == ('joined at a branch target',)` check in the new `exec_zero_join` set can be replaced by `True` without any test failing. Either add a case where the register is not in the joined state, or drop the check if it is redundant with the other conditions. 4. The other mutations are caught: `s_orn2_b64` removed from the accepted forms, and the `exec` operand check removed. 5. Lowering emits `(exec & s16) & 1` and `(s16 | ~exec) & 1`. The reasoning in the docstring is sound for a one-lane model (a taken execz edge means exec bit 0 is 0). The change is an operand-reading rule, not new arithmetic, so I did not ask for a new WARP readback, but the test does compare the generated HLSL, not GPU output. Please say whether a readback is wanted here. Not a blocker on its own, but I would fix 1 and 2 before merge: these are the guards that keep compute stages and fall-through-less targets refused. Commands run locally: - `python3 tests/startup_gfx2hlsl_join_symbols_check.py` : exit 0, both summary lines - `git diff --check origin/main...HEAD` : clean - 5 manual mutations of `gfx2hlsl.py` (cs exclusion, `falls`, sym check, orn2, exec operand): 3 survived (items 1-3), 2 caught; tree restored with `git checkout -- .` No Win2025 run and no game run were done by this review. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-25 20:04:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:59:31Z.

Review: APPROVED


Approved at head 8c9d7a96. That is d7ce3abc, with the controls that closed my review, plus a merge of main.

Conflict resolution

  • The resolution: in Stage.scalar, main's short-operand-list guard (needed from the template placeholders) now runs before exec_absorbed_source.
  • Why that's sound: a short operand list is refused before the absorbed read can index srcs, and every list that passes has the two sources exec_absorbed_source requires.

Commands executed at 8c9d7a96 (Windows 11 build 26300, Python 3.13)

python -B tests/startup_gfx2hlsl_join_symbols_check.py
python -B tests/startup_gfx2hlsl_{operand_count,handler_arity}_check.py
python -B tests/startup_translator_check.py

All exit 0. The head merges cleanly with current main.

Negative control (re-run after the merge)

Each mutation is applied to tools/startup/gfx2hlsl.py alone, then reverted:

mutation join_symbols_check
"forward only" dropped (all(names[pc] == 's_cbranch_execz' …)) exit 1 (it survived at baafda83)
compute exclusion removed (set() if False else …) exit 1 (it survived at baafda83)
s_orn2_b64 with exec as src0 accepted exit 1
"only the instruction at the target" dropped exit 1

The falls control and the plain-on-every-path control @NiiRoZz added cover @tedin7's and @ChazY11's survivors too. Removing the redundant joined-marker check is fine, since that control pins the output.

Merge checks: required CI passed at this head. The /O2 and coverage skips come from explicit workflow conditions. There are no unresolved review threads. I read the whole thread, including @tedin7's review and the author's responses.

The change is text-level under the translator's one-lane model, as the docs say. @tedin7 asked whether a readback is wanted; it isn't needed for this operand-reading rule.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064115129 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#pullrequestreview-6064115129). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T19:59:31Z. **Review:** APPROVED --- Approved at head `8c9d7a96`. That is `d7ce3abc`, with the controls that closed my review, plus a merge of `main`. ### Conflict resolution - **The resolution:** in `Stage.scalar`, `main`'s short-operand-list guard (`needed` from the template placeholders) now runs before `exec_absorbed_source`. - **Why that's sound:** a short operand list is refused before the absorbed read can index `srcs`, and every list that passes has the two sources `exec_absorbed_source` requires. ### Commands executed at `8c9d7a96` (Windows 11 build 26300, Python 3.13) ```powershell python -B tests/startup_gfx2hlsl_join_symbols_check.py python -B tests/startup_gfx2hlsl_{operand_count,handler_arity}_check.py python -B tests/startup_translator_check.py ``` All exit 0. The head merges cleanly with current `main`. ### Negative control (re-run after the merge) Each mutation is applied to `tools/startup/gfx2hlsl.py` alone, then reverted: | mutation | `join_symbols_check` | |---|---| | "forward only" dropped (`all(names[pc] == 's_cbranch_execz' …)`) | exit 1 (it survived at `baafda83`) | | compute exclusion removed (`set() if False else …`) | exit 1 (it survived at `baafda83`) | | `s_orn2_b64` with exec as `src0` accepted | exit 1 | | "only the instruction at the target" dropped | exit 1 | The `falls` control and the plain-on-every-path control @NiiRoZz added cover @tedin7's and @ChazY11's survivors too. Removing the redundant joined-marker check is fine, since that control pins the output. Merge checks: required CI passed at this head. The `/O2` and coverage skips come from explicit workflow conditions. There are no unresolved review threads. I read the whole thread, including @tedin7's review and the author's responses. The change is text-level under the translator's one-lane model, as the docs say. @tedin7 asked whether a readback is wanted; it isn't needed for this operand-reading rule. AI-assisted; commands listed were executed locally.
NiiRoZz commented 2026-11-25 20:04:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T19:51:45Z.


Thanks for the mutation runs. I reproduced each one at d5658cdd (apply the mutation, run tests/startup_gfx2hlsl_join_symbols_check.py, revert) and pushed the result as d7ce3abc on top.

Mutations are on execz_targets and exec_zero_join in tools/startup/gfx2hlsl.py. "exit 0" means the check passed, so the mutation survived. "exit 1" means it was caught.

Mutation table

mutation before (d5658cdd) after (d7ce3abc)
compute exclusion removed (set() if False else ...) exit 0, survived exit 1, caught
"forward only" dropped (all(names[pc] == 's_cbranch_execz' ...)) exit 0, survived exit 1, caught
falls requirement dropped exit 0, survived exit 1, caught
sym == joined marker replaced by True exit 0, survived no longer applies (see below)
all(...) to any(...) exit 1, caught exit 1, caught
branch kind dropped (all(pc < t ...)) exit 1, caught exit 1, caught
arriving[0][0][reg] is None to True exit 1, caught exit 1, caught
s_orn2_b64 removed from the accepted forms exit 1, caught exit 1, caught
exec operand check removed exit 1, caught exit 1, caught

ChazY11

  1. Compute exclusion. Verdict: test gap, and also a mutation that cannot change a real compute result.
    • Run through the real compute pipeline, the mutation changes nothing. Any program with this shape has a definition inside the skipped block that the target reads. The compute pre-pass (execz_refusals) refuses that first, with "definition of sN, live where the block joins", before the join code runs. The refusal lists with and without the exclusion were identical.
    • So the exclusion is a second guard behind the pre-pass. I kept it and pinned it in isolation.
    • New control: a compute program of this shape (descriptor word in s12, lane mask written in the skipped block, s_and_b64 s12, s12, exec at the target).
      • With the pre-pass in place it is refused by the pre-pass.
      • With the pre-pass stubbed out it is refused as numeric use of s12 holding joined at a branch target, the old refusal.
    • Removing the exclusion makes the second assertion fail.
  2. falls requirement. Verdict: test gap. I could not see a changed result at first because the case I tried was accepted either way.
    • The case that separates them: s16 is plain at the first skipping s_cbranch_execz, a descriptor load follows, a second skipping s_cbranch_execz follows, then s_endpgm, then the target. No fall-through enters.
    • Without the falls requirement the first edge is treated as the fall-through and the read is accepted. The new control asserts the old refusal. It decodes the program to check that the instruction before the target is s_endpgm.
  3. Joined-marker check. Verdict: redundant, removed.
    • A register at the target is either the joined marker or a plain variable.
    • For a plain variable, skipping the usual numeric read gives the same text, so the check changes no output. The same check existed twice (in the set and at the point of use).
    • I removed both. A new control asserts the plain-on-every-path read is the ordinary s16 = (s16 & exec) & 1;.
    • This leaves no marker conjunct to mutate.

MasterDomino

  1. Forward only. Verdict: test gap. New control: L: s_and_b64 s16, s16, exec followed by s_cbranch_execz L (backward), reached by a forward skipping edge too. It asserts the old refusal and decodes the program to check that the last s_cbranch_execz targets an earlier label.
  2. Compute exclusion. As above. I could not make the compute program reach the old numeric use refusal through the real pipeline, because the pre-pass refuses it first. The stubbed-pre-pass control gives exactly that refusal, so the condition is stated in the fixture.

tedin7

  1. Compute exclusion. As above.
  2. falls. As above.
  3. Joined marker. Redundant, removed, as above.
  4. Noted. These two mutations were already caught and still are.
  5. Readback. Verdict: not added. The rule only changes which operands are read in the generated text and relies on the one-lane model, as the docs say. The new controls are also text-level. A WARP readback of the whole pattern is possible if you want one; I did not run one.

Commands and results (head d7ce3abc, Windows, Python 3.13, python -B)

  • tests/startup_gfx2hlsl_join_symbols_check.py: exit 0, both summary lines (the join line now reports 17 refusal controls, counted by the check).
  • tests/startup_translator_check.py: 0 failed.
  • tests/docs_links_check.py: 19 Markdown files, 469 links.
  • every tests/startup_gfx2hlsl_*_check.py run with no arguments: 66 files, all exit 0.
  • git diff --check origin/main...HEAD: clean.

Not run

  • No CMake build, no ctest, no GPU or WARP run. The dispatch, control and binary modes of the join check were not run.
  • The new words are built from field layouts and checked against the decoder text. They are not assembled with LLVM.
  • The branch was not merged with current main.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172863499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#issuecomment-7172863499). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T19:51:45Z. --- Thanks for the mutation runs. I reproduced each one at d5658cdd (apply the mutation, run `tests/startup_gfx2hlsl_join_symbols_check.py`, revert) and pushed the result as d7ce3abc on top. Mutations are on `execz_targets` and `exec_zero_join` in `tools/startup/gfx2hlsl.py`. "exit 0" means the check passed, so the mutation survived. "exit 1" means it was caught. ## Mutation table | mutation | before (d5658cdd) | after (d7ce3abc) | |---|---|---| | compute exclusion removed (`set() if False else ...`) | exit 0, survived | exit 1, caught | | "forward only" dropped (`all(names[pc] == 's_cbranch_execz' ...)`) | exit 0, survived | exit 1, caught | | `falls` requirement dropped | exit 0, survived | exit 1, caught | | `sym == joined marker` replaced by `True` | exit 0, survived | no longer applies (see below) | | `all(...)` to `any(...)` | exit 1, caught | exit 1, caught | | branch kind dropped (`all(pc < t ...)`) | exit 1, caught | exit 1, caught | | `arriving[0][0][reg] is None` to `True` | exit 1, caught | exit 1, caught | | `s_orn2_b64` removed from the accepted forms | exit 1, caught | exit 1, caught | | `exec` operand check removed | exit 1, caught | exit 1, caught | ## ChazY11 1. Compute exclusion. Verdict: test gap, and also a mutation that cannot change a real compute result. - Run through the real compute pipeline, the mutation changes nothing. Any program with this shape has a definition inside the skipped block that the target reads. The compute pre-pass (`execz_refusals`) refuses that first, with "definition of sN, live where the block joins", before the join code runs. The refusal lists with and without the exclusion were identical. - So the exclusion is a second guard behind the pre-pass. I kept it and pinned it in isolation. - New control: a compute program of this shape (descriptor word in s12, lane mask written in the skipped block, `s_and_b64 s12, s12, exec` at the target). - With the pre-pass in place it is refused by the pre-pass. - With the pre-pass stubbed out it is refused as `numeric use of s12 holding joined at a branch target`, the old refusal. - Removing the exclusion makes the second assertion fail. 2. `falls` requirement. Verdict: test gap. I could not see a changed result at first because the case I tried was accepted either way. - The case that separates them: s16 is plain at the first skipping `s_cbranch_execz`, a descriptor load follows, a second skipping `s_cbranch_execz` follows, then `s_endpgm`, then the target. No fall-through enters. - Without the `falls` requirement the first edge is treated as the fall-through and the read is accepted. The new control asserts the old refusal. It decodes the program to check that the instruction before the target is `s_endpgm`. 3. Joined-marker check. Verdict: redundant, removed. - A register at the target is either the joined marker or a plain variable. - For a plain variable, skipping the usual numeric read gives the same text, so the check changes no output. The same check existed twice (in the set and at the point of use). - I removed both. A new control asserts the plain-on-every-path read is the ordinary `s16 = (s16 & exec) & 1;`. - This leaves no marker conjunct to mutate. ## MasterDomino 1. Forward only. Verdict: test gap. New control: `L: s_and_b64 s16, s16, exec` followed by `s_cbranch_execz L` (backward), reached by a forward skipping edge too. It asserts the old refusal and decodes the program to check that the last `s_cbranch_execz` targets an earlier label. 2. Compute exclusion. As above. I could not make the compute program reach the old `numeric use` refusal through the real pipeline, because the pre-pass refuses it first. The stubbed-pre-pass control gives exactly that refusal, so the condition is stated in the fixture. ## tedin7 1. Compute exclusion. As above. 2. `falls`. As above. 3. Joined marker. Redundant, removed, as above. 4. Noted. These two mutations were already caught and still are. 5. Readback. Verdict: not added. The rule only changes which operands are read in the generated text and relies on the one-lane model, as the docs say. The new controls are also text-level. A WARP readback of the whole pattern is possible if you want one; I did not run one. ## Commands and results (head d7ce3abc, Windows, Python 3.13, `python -B`) - `tests/startup_gfx2hlsl_join_symbols_check.py`: exit 0, both summary lines (the join line now reports 17 refusal controls, counted by the check). - `tests/startup_translator_check.py`: 0 failed. - `tests/docs_links_check.py`: 19 Markdown files, 469 links. - every `tests/startup_gfx2hlsl_*_check.py` run with no arguments: 66 files, all exit 0. - `git diff --check origin/main...HEAD`: clean. ## Not run - No CMake build, no ctest, no GPU or WARP run. The `dispatch`, `control` and `binary` modes of the join check were not run. - The new words are built from field layouts and checked against the decoder text. They are not assembled with LLVM. - The branch was not merged with current `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MasterDomino commented 2026-11-25 20:04:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:54:22Z.


Re-checked at d7ce3abc. Thanks, @NiiRoZz.

  • Check: tests/startup_gfx2hlsl_join_symbols_check.py passes.
  • My two survivors from the review of baafda83 are now caught. Dropping "forward only" (all(pc < t and names[pc] == …) changed to all(names[pc] == …)) fails the check with exit 1, and so does removing the compute exclusion (set() if False else …). Both reverted.
  • Removing the redundant joined-marker check is fine by me, given the control that pins the plain-on-every-path read.

One thing left: the branch now conflicts with main in tools/startup/gfx2hlsl.py (git merge-tree). Once it's rebased and CI is green, I'll recheck the head and merge.

AI-assisted; commands executed locally (Windows 11 build 26300, Python 3.13).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172924350 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#issuecomment-7172924350). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T19:54:22Z. --- Re-checked at `d7ce3abc`. Thanks, @NiiRoZz. - **Check:** `tests/startup_gfx2hlsl_join_symbols_check.py` passes. - **My two survivors from the review of `baafda83` are now caught.** Dropping "forward only" (`all(pc < t and names[pc] == …)` changed to `all(names[pc] == …)`) fails the check with exit 1, and so does removing the compute exclusion (`set() if False else …`). Both reverted. - **Removing the redundant joined-marker check** is fine by me, given the control that pins the plain-on-every-path read. One thing left: the branch now conflicts with `main` in `tools/startup/gfx2hlsl.py` (`git merge-tree`). Once it's rebased and CI is green, I'll recheck the head and merge. AI-assisted; commands executed locally (Windows 11 build 26300, Python 3.13).
NiiRoZz commented 2026-11-25 20:04:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T19:54:30Z.


Current main is merged in at 8c9d7a96. One conflict, in tools/startup/gfx2hlsl.py: main's short-operand-list guard now runs first, then this PR's exec-absorbed read. Re-run at that head: startup_gfx2hlsl_join_symbols_check.py, startup_translator_check.py and every no-argument startup_gfx2hlsl_*_check.py, all exit 0. The reviewer mutations were not re-run after the merge.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172927420 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2466#issuecomment-7172927420). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T19:54:30Z. --- Current `main` is merged in at `8c9d7a96`. One conflict, in `tools/startup/gfx2hlsl.py`: main's short-operand-list guard now runs first, then this PR's exec-absorbed read. Re-run at that head: `startup_gfx2hlsl_join_symbols_check.py`, `startup_translator_check.py` and every no-argument `startup_gfx2hlsl_*_check.py`, all exit 0. The reviewer mutations were not re-run after the merge.
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!2458
No description provided.