compute: prove a loop break inside a block s_cbranch_execz skips (task list) #2637

Open
opened 2026-11-26 00:20:41 +00:00 by NiiRoZz · 11 comments
NiiRoZz commented 2026-11-26 00:20:41 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-26T00:20:41Z.


Problem

Part of #2274 (section A, execz handling). Refs #1723.

In one local run of the compute path, 27 compute programs (761,026 dispatches) were first refused by the translator with s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block: the path that stays does not go on at the join (counts only; not reproducible from the repository). The reason text and the exit proof it belongs to are not on main yet; they come from the local branch stacked on #2557, where a branch out of a block that s_cbranch_execz skips is accepted only as the "lane mask exhausted" exit, with the path that stays going straight on at the join. On main the same programs are refused earlier, as a branch out of the block.

26 of the 27 (756,551 dispatches) have one shape, a loop break inside the skipped block:

    v_cmpx_...                            ; lanes that break
    s_andn2_b32    sM, sM, exec_lo        ; sM: lanes still in the loop
    s_andn2_b32    sN, sN, exec_lo        ; sN: a second saved mask
    s_cbranch_scc0 X                      ; no lane left: leave the loop
    s_mov_b32      exec_lo, sM            ; path that stays
    v_mov ...                             ; 1 or 2 moves
    s_mov_b32      exec_lo, sN            ; the join of the skipped block
    s_add_u32      sC, sC, 1
    s_cmp_ge_u32   sC, <n>
    s_cbranch_scc0 loop_head              ; backward
    s_and_b32      sA, sA, exec_lo
    s_or_b32       sB, sB, sA             ; accumulated lane mask
X:  ...scalar loads...
    s_mov_b32      exec_lo, sSaved

Four conditions of that proof fail at once, so this is not a near form of the accepted exit:

  1. On the path that stays, exec comes from a second saved mask. Proving it clear for a skipped lane needs "exec at the branch is a subset of that mask", a relation set up before the block that the translator does not track.
  2. The range between the join and the exit target contains the loop's backward branch.
  3. The exit target is not an exec rewrite: scalar loads come before the move into exec.
  4. An accumulated lane mask is defined between the join and the exit target and is live at the exit target.

The 27th program (4,475 dispatches) is a wave64 form where only the "stays at the join" condition failed. A local change accepts a straight run between the branch and the join when every vector instruction in it runs with exec proven clear; that program then stops at a live-definition refusal, so the change translates nothing on its own and is not proposed here.

Proposal

A loop-break proof for the one-lane model, in claimable pieces:

  • T1: mask subset facts. Carry, into a skipped block, the fact that exec at the branch is a subset of a saved mask (set by s_mov_b32 sM, exec_lo or an s_and_b32 with exec before the block, with no write of the mask since). With it, s_mov_b32 exec_lo, sM on the path that stays keeps a skipped lane's bit clear exactly when that lane's bit of sM is clear, which the existing clear-mask step can then use.
  • T2: a backward branch between the join and the exit target. State and prove what the model does for a lane that the wave sends round the loop again while the model has left, and the reverse; accept the counted form above (s_add_u32, s_cmp_ge_u32, s_cbranch_scc0 to the head) or keep it refused with its own reason.
  • T3: an exit target that is a scalar run before the exec rewrite. Allow scalar instructions without effects outside registers between the target and the move into exec.
  • T4: an accumulated lane mask live at the exit target. s_and_b32 sA, sA, exec_lo then s_or_b32 sB, sB, sA only moves a lane's own bit; prove it lane-kept the way the if-conversion mask of #2505 is, and require every later read to be per lane.

Each task: a hand-assembled check case on which the check's wave interpreter and lane interpreter agree, one near-miss per condition that stays refused and shows the lane disagreement, and the accepted case refused again with the change reverted.

Alternatives

  • Lower the whole loop with wave intrinsics instead of the one-lane model: a larger change, and it leaves the model for every program with such a loop.
  • Leave it refused: these programs then stay untranslated; in the run above this reason was the third largest translator refusal by dispatches.

Verification

  • Per task as above. No D3D12 work is needed; the translator checks run on every platform.
  • Measured so far: the classification in one local run, and that the straight-run change moves the 26 programs to v_mov_b32_e32 on the path that stays with exec not proven clear without translating any. That T1 to T4 together let them translate is a hypothesis; the next refusal after them was not observed.

Checklist

  • I checked for an existing issue or pull request for this change.
  • I did not include game files, dumps, distribution links or credentials.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6616574554 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-26T00:20:41Z. --- ## Problem Part of #2274 (section A, execz handling). Refs #1723. In one local run of the compute path, 27 compute programs (761,026 dispatches) were first refused by the translator with `s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block: the path that stays does not go on at the join` (counts only; not reproducible from the repository). The reason text and the exit proof it belongs to are not on main yet; they come from the local branch stacked on #2557, where a branch out of a block that `s_cbranch_execz` skips is accepted only as the "lane mask exhausted" exit, with the path that stays going straight on at the join. On main the same programs are refused earlier, as a branch out of the block. 26 of the 27 (756,551 dispatches) have one shape, a loop break inside the skipped block: ``` v_cmpx_... ; lanes that break s_andn2_b32 sM, sM, exec_lo ; sM: lanes still in the loop s_andn2_b32 sN, sN, exec_lo ; sN: a second saved mask s_cbranch_scc0 X ; no lane left: leave the loop s_mov_b32 exec_lo, sM ; path that stays v_mov ... ; 1 or 2 moves s_mov_b32 exec_lo, sN ; the join of the skipped block s_add_u32 sC, sC, 1 s_cmp_ge_u32 sC, <n> s_cbranch_scc0 loop_head ; backward s_and_b32 sA, sA, exec_lo s_or_b32 sB, sB, sA ; accumulated lane mask X: ...scalar loads... s_mov_b32 exec_lo, sSaved ``` Four conditions of that proof fail at once, so this is not a near form of the accepted exit: 1. On the path that stays, exec comes from a second saved mask. Proving it clear for a skipped lane needs "exec at the branch is a subset of that mask", a relation set up before the block that the translator does not track. 2. The range between the join and the exit target contains the loop's backward branch. 3. The exit target is not an exec rewrite: scalar loads come before the move into exec. 4. An accumulated lane mask is defined between the join and the exit target and is live at the exit target. The 27th program (4,475 dispatches) is a wave64 form where only the "stays at the join" condition failed. A local change accepts a straight run between the branch and the join when every vector instruction in it runs with exec proven clear; that program then stops at a live-definition refusal, so the change translates nothing on its own and is not proposed here. ## Proposal A loop-break proof for the one-lane model, in claimable pieces: - [ ] **T1: mask subset facts.** Carry, into a skipped block, the fact that exec at the branch is a subset of a saved mask (set by `s_mov_b32 sM, exec_lo` or an `s_and_b32` with exec before the block, with no write of the mask since). With it, `s_mov_b32 exec_lo, sM` on the path that stays keeps a skipped lane's bit clear exactly when that lane's bit of `sM` is clear, which the existing clear-mask step can then use. - [ ] **T2: a backward branch between the join and the exit target.** State and prove what the model does for a lane that the wave sends round the loop again while the model has left, and the reverse; accept the counted form above (`s_add_u32`, `s_cmp_ge_u32`, `s_cbranch_scc0` to the head) or keep it refused with its own reason. - [ ] **T3: an exit target that is a scalar run before the exec rewrite.** Allow scalar instructions without effects outside registers between the target and the move into exec. - [ ] **T4: an accumulated lane mask live at the exit target.** `s_and_b32 sA, sA, exec_lo` then `s_or_b32 sB, sB, sA` only moves a lane's own bit; prove it lane-kept the way the if-conversion mask of #2505 is, and require every later read to be per lane. Each task: a hand-assembled check case on which the check's wave interpreter and lane interpreter agree, one near-miss per condition that stays refused and shows the lane disagreement, and the accepted case refused again with the change reverted. ## Alternatives - Lower the whole loop with wave intrinsics instead of the one-lane model: a larger change, and it leaves the model for every program with such a loop. - Leave it refused: these programs then stay untranslated; in the run above this reason was the third largest translator refusal by dispatches. ## Verification - Per task as above. No D3D12 work is needed; the translator checks run on every platform. - Measured so far: the classification in one local run, and that the straight-run change moves the 26 programs to `v_mov_b32_e32 on the path that stays with exec not proven clear` without translating any. That T1 to T4 together let them translate is a hypothesis; the next refusal after them was not observed. ## Checklist - [x] I checked for an existing issue or pull request for this change. - [x] I did not include game files, dumps, distribution links or credentials. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
triggered02 commented 2026-11-26 04:04:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T03:38:41Z.


Triaging this as a task-list item rather than a bug on main, and naming what is missing:

What main does today. The same programs are refused earlier, as a branch out of the block � the reason text and the exit proof you describe live only on your local branch stacked on #2557. So there is nothing on main that can be tested against the 26-program shape yet; the count (27 programs / 761,026 dispatches) cannot be reproduced from the repository as it stands.

Smallest useful step. Land the two things that are source-buildable in this repo, in this order: (1) a synthetic fixture that reproduces the shape � two saved exec masks via s_andn2_b32, s_cbranch_scc0 when no lane remains, the staying path remasking exec_lo and reaching the join, plus the join after the skipped block � with the expected per-lane result spelled out; (2) the bounded refusal/acceptance reason string from the #2557 stack, so the census separates "loop break inside a skipped block" from the generic "branch out of the block". With (1) alone the refusal is pinned as fail-first; (2) is what makes the count attributable.

What I am not claiming. That main accepts this shape after (1) � it does not; (1) is the fixture for the acceptance work, not the acceptance itself.

If you can attach the synthetic assembly for one of the 26 (the loop skeleton with the two saved masks and the join), I will build the fixture from it and keep #2274 section A as the parent.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181898969 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7181898969). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-26T03:38:41Z. --- Triaging this as a task-list item rather than a bug on main, and naming what is missing: **What main does today.** The same programs are refused earlier, as a branch out of the block � the reason text and the exit proof you describe live only on your local branch stacked on #2557. So there is nothing on main that can be tested against the 26-program shape yet; the count (27 programs / 761,026 dispatches) cannot be reproduced from the repository as it stands. **Smallest useful step.** Land the two things that are source-buildable in this repo, in this order: (1) a synthetic fixture that reproduces the shape � two saved exec masks via s_andn2_b32, s_cbranch_scc0 when no lane remains, the staying path remasking exec_lo and reaching the join, plus the join after the skipped block � with the expected per-lane result spelled out; (2) the bounded refusal/acceptance reason string from the #2557 stack, so the census separates "loop break inside a skipped block" from the generic "branch out of the block". With (1) alone the refusal is pinned as fail-first; (2) is what makes the count attributable. **What I am not claiming.** That main accepts this shape after (1) � it does not; (1) is the fixture for the acceptance work, not the acceptance itself. If you can attach the synthetic assembly for one of the 26 (the loop skeleton with the two saved masks and the join), I will build the fixture from it and keep #2274 section A as the parent.
R0Y00 commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T04:30:15Z.


The prerequisite #2557 is now on main at 1226f02e. Please base the existing loop-exit experiment on that revision or newer. A small source-built pair can now isolate the next proof: one loop that exits only through the execz-skipped block, and one with an additional live or bypass edge that must be refused. Please show the first diagnostic for the negative and the exact readback for the accepted variant before extending the corpus result.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182651589 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7182651589). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T04:30:15Z. --- The prerequisite #2557 is now on main at 1226f02e. Please base the existing loop-exit experiment on that revision or newer. A small source-built pair can now isolate the next proof: one loop that exits only through the execz-skipped block, and one with an additional live or bypass edge that must be refused. Please show the first diagnostic for the negative and the exact readback for the accepted variant before extending the corpus result.
RonLogic commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:34:06Z.


@triggered02 I built the small synthetic Wave32 skeleton you asked for, now that #2557 is on main. This covers the two saved masks, branch from inside the skipped block, remask on the staying path, backward counted edge, and scalar instructions before the final EXEC restore. The accumulated/live mask in T4 is outside this skeleton. No title input or runtime changes.

Use the same root and compute state as case O of tests/startup_gfx2hlsl_compute_check.py (8×1×1). For one group, the first eight output words should be [9, 1, 2, 9, 9, 9, 9, 9]. A small CPU trace of the wave and individual lanes agreed. On the translator from 1226f02e plus the unrelated gather diagnostic, the bytes below decoded as shown and reached the refusal s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block. That is the expected fail-first observation.

v_lshlrev_b32 v4, 2, v0
v_mov_b32 v5, 9
s_mov_b32 s21, exec_lo
v_cmp_gt_u32 vcc_lo, 3, v0
s_and_b32 s22, exec_lo, vcc_lo
s_mov_b32 s23, s22
s_mov_b32 s24, 1
head:
s_mov_b32 exec_lo, s22
s_cbranch_execz join
v_cmpx_gt_u32 s24, v0
s_andn2_b32 s22, s22, exec_lo
s_andn2_b32 s23, s23, exec_lo
s_cbranch_scc0 exit
s_mov_b32 exec_lo, s22
v_mov_b32 v5, s24
join:
s_mov_b32 exec_lo, s23
s_add_u32 s24, s24, 1
s_cmp_ge_u32 s24, 4
s_cbranch_scc0 head
exit:
s_mov_b32 s10, s6
s_mov_b32 s11, 0
s_load_dwordx8 s[12:19], s[10:11], 0x0
s_waitcnt lgkmcnt(0)
s_mov_b32 exec_lo, s21
buffer_store_dword v5, v4, s[16:19], 0 offen
s_endpgm
82000834 89020a7e 7e0395be 8300887d 7e6a1687 160397be 810398be
1603febe 060088bf 1800a87d 167e168a 177e178a 060084bf 1603febe
18020a7e 1703febe 18811880 188409bf f4ff84bf 06038abe 80038bbe
05030cf4000000fa 7fc08cbf 1503febe 001070e004050480 000081bf

I used the repository decoder to verify the hand-encoded words on Windows. Please use the skeleton in the fixture you offered to build. I can independently check the proof and near-miss once a branch is available.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182707854 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7182707854). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-26T04:34:06Z. --- @triggered02 I built the small synthetic Wave32 skeleton you asked for, now that #2557 is on main. This covers the two saved masks, branch from inside the skipped block, remask on the staying path, backward counted edge, and scalar instructions before the final EXEC restore. The accumulated/live mask in T4 is outside this skeleton. No title input or runtime changes. Use the same root and compute state as case O of `tests/startup_gfx2hlsl_compute_check.py` (8×1×1). For one group, the first eight output words should be `[9, 1, 2, 9, 9, 9, 9, 9]`. A small CPU trace of the wave and individual lanes agreed. On the translator from `1226f02e` plus the unrelated gather diagnostic, the bytes below decoded as shown and reached the refusal `s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block`. That is the expected fail-first observation. ```asm v_lshlrev_b32 v4, 2, v0 v_mov_b32 v5, 9 s_mov_b32 s21, exec_lo v_cmp_gt_u32 vcc_lo, 3, v0 s_and_b32 s22, exec_lo, vcc_lo s_mov_b32 s23, s22 s_mov_b32 s24, 1 head: s_mov_b32 exec_lo, s22 s_cbranch_execz join v_cmpx_gt_u32 s24, v0 s_andn2_b32 s22, s22, exec_lo s_andn2_b32 s23, s23, exec_lo s_cbranch_scc0 exit s_mov_b32 exec_lo, s22 v_mov_b32 v5, s24 join: s_mov_b32 exec_lo, s23 s_add_u32 s24, s24, 1 s_cmp_ge_u32 s24, 4 s_cbranch_scc0 head exit: s_mov_b32 s10, s6 s_mov_b32 s11, 0 s_load_dwordx8 s[12:19], s[10:11], 0x0 s_waitcnt lgkmcnt(0) s_mov_b32 exec_lo, s21 buffer_store_dword v5, v4, s[16:19], 0 offen s_endpgm ``` ```text 82000834 89020a7e 7e0395be 8300887d 7e6a1687 160397be 810398be 1603febe 060088bf 1800a87d 167e168a 177e178a 060084bf 1603febe 18020a7e 1703febe 18811880 188409bf f4ff84bf 06038abe 80038bbe 05030cf4000000fa 7fc08cbf 1503febe 001070e004050480 000081bf ``` I used the repository decoder to verify the hand-encoded words on Windows. Please use the skeleton in the fixture you offered to build. I can independently check the proof and near-miss once a branch is available.
triggered02 commented 2026-11-26 06:02:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T05:06:57Z.


Measured census data for this task list, from a run of main at fd033046 with the shader translator writing per-request status lines. Counts only; no game data, paths or shader text.

count refusal text
25 s_branch inside a block s_cbranch_execz skips per lane: branch out of the block
10 s_cbranch_execz inside a block s_cbranch_execz skips per lane: branch out of the block
9 v_cmp_gt_i32_e32 inside a block s_cbranch_execz skips per lane: definition of vcc_hi, live where the block joins

That is 44 refused programs in this census whose primary refusal is the execz-block branch shape this task list tracks, so the "counts only, not reproducible from the repository" caveat in the issue body now has a second, independent measurement attached to it.

Two of the three are plain s_branch/s_cbranch_execz out of the skipped block; the third is the VCC-liveness variant (v_cmp_gt_i32_e32 defining vcc_hi that is live at the join), which is a different proof obligation and probably a separate slice from the loop-break shape.

Next step stays what the issue says: a synthetic fixture for the two-saved-mask loop break (s_andn2_b32 twice, s_cbranch_scc0 when no lane remains, the staying path remasking exec_lo, join after the block), with the VCC-liveness case as a separate refusal pin. If whoever takes that slice wants the raw per-request figures, they are in the run's translate log by count only.

AI-assisted; counts from the run's translate log.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7183193487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7183193487). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-26T05:06:57Z. --- Measured census data for this task list, from a run of `main` at `fd033046` with the shader translator writing per-request status lines. Counts only; no game data, paths or shader text. | count | refusal text | |---|---| | 25 | `s_branch inside a block s_cbranch_execz skips per lane: branch out of the block` | | 10 | `s_cbranch_execz inside a block s_cbranch_execz skips per lane: branch out of the block` | | 9 | `v_cmp_gt_i32_e32 inside a block s_cbranch_execz skips per lane: definition of vcc_hi, live where the block joins` | That is 44 refused programs in this census whose primary refusal is the execz-block branch shape this task list tracks, so the "counts only, not reproducible from the repository" caveat in the issue body now has a second, independent measurement attached to it. Two of the three are plain `s_branch`/`s_cbranch_execz` out of the skipped block; the third is the VCC-liveness variant (`v_cmp_gt_i32_e32` defining `vcc_hi` that is live at the join), which is a different proof obligation and probably a separate slice from the loop-break shape. Next step stays what the issue says: a synthetic fixture for the two-saved-mask loop break (`s_andn2_b32` twice, `s_cbranch_scc0` when no lane remains, the staying path remasking `exec_lo`, join after the block), with the VCC-liveness case as a separate refusal pin. If whoever takes that slice wants the raw per-request figures, they are in the run's translate log by count only. AI-assisted; counts from the run's translate log.
stan495 commented 2026-11-26 15:57:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-26T15:57:36Z.


Updated https://github.com/R0Y00/Xbox2Windows/pull/2877 at commit \33b4e3d0\ (fixed the \s_cbranch_scc0 6\n\ replacement in \O-loop-subset\ so the \s_cbranch_scc0 65524\ latch keeps its opcode for \llvm-mc-15). Re-ran \ ests/startup_gfx2hlsl_compute_check.py, \ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'\ (71/71 on WARP + \AMD Radeon RX 7900 XTX, debug layer enabled), and \ ools/run_checks_parallel.py -j 4 --from-dir tests/checks/python-linux\ (5/5 passed).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7196985485 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7196985485). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T15:57:36Z. --- Updated https://github.com/R0Y00/Xbox2Windows/pull/2877 at commit \33b4e3d0\ (fixed the \s_cbranch_scc0 6\n\ replacement in \O-loop-subset\ so the \s_cbranch_scc0 65524\ latch keeps its opcode for \llvm-mc-15\). Re-ran \ ests/startup_gfx2hlsl_compute_check.py\, \ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'\ (71/71 on WARP + \AMD Radeon RX 7900 XTX\, debug layer enabled), and \ ools/run_checks_parallel.py -j 4 --from-dir tests/checks/python-linux\ (5/5 passed).
stan495 commented 2026-11-26 16:04:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-26T15:49:36Z.


Claiming T1 (mask subset facts) in \ ools/startup/gfx2hlsl.py\ (\Stage.execz_refusals).

Plan:

  • Compute forward must-dataflow of pre-branch mask-subset facts (scalar words whose bits are guaranteed clear wherever current \exec\ is clear: initialized by \s_mov_b32 sM, exec_lo, \s_and_b32 sM, exec_lo, X, \s_mov_b32 exec_lo, sM, 64-bit counterparts, and preserved across subset-preserving bitwise steps via \clear_after; dropped on non-subset rewrites, narrowing/unproven \exec\ writes on that half, and joins where any incoming edge lacks the fact).
  • Seed \efore[b + 1]\ in \execz_refusals\ with those proven subset facts alongside 'exec', 0), ('exec_hi', 1)\ (keeping the \exec\-only invariant set for the per-instruction \exec write\ check and loop floor so overwritten saved masks cannot re-enter \fter.
  • Keep \T2\ (\loop exit crosses a backward s_cbranch_scc0), \T3, and \T4\ refused untouched so only \T1\ changes.
  • Verify with source-built / \llvm-mc-assembled compute fixtures in \ ests/startup_gfx2hlsl_compute_check.py: wave vs singleton lane trace agreement, near-miss refusal controls (pre-branch narrowing \exec, pre-branch/in-block mask overwrite, join lacking fact on one arm), DXC \cs_6_0\ dispatch readback on WARP and \AMD Radeon RX 7900 XTX\ (debug layer enabled) on a loop/straight \execz\ break-without-exit variant, plus \LOOP_BREAK_WORDS\ still keeping its \T2\ refusal while dropping the \T1\ \exec write\ refusal.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7196803351 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7196803351). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T15:49:36Z. --- Claiming **T1 (mask subset facts)** in \ ools/startup/gfx2hlsl.py\ (\Stage.execz_refusals\). **Plan:** - Compute forward must-dataflow of pre-branch mask-subset facts (scalar words whose bits are guaranteed clear wherever current \exec\ is clear: initialized by \s_mov_b32 sM, exec_lo\, \s_and_b32 sM, exec_lo, X\, \s_mov_b32 exec_lo, sM\, 64-bit counterparts, and preserved across subset-preserving bitwise steps via \clear_after\; dropped on non-subset rewrites, narrowing/unproven \exec\ writes on that half, and joins where any incoming edge lacks the fact). - Seed \efore[b + 1]\ in \execz_refusals\ with those proven subset facts alongside \('exec', 0), ('exec_hi', 1)\ (keeping the \exec\-only invariant set for the per-instruction \exec write\ check and loop floor so overwritten saved masks cannot re-enter \fter\). - Keep \T2\ (\loop exit crosses a backward s_cbranch_scc0\), \T3\, and \T4\ refused untouched so only \T1\ changes. - Verify with source-built / \llvm-mc\-assembled compute fixtures in \ ests/startup_gfx2hlsl_compute_check.py\: wave vs singleton lane trace agreement, near-miss refusal controls (pre-branch narrowing \exec\, pre-branch/in-block mask overwrite, join lacking fact on one arm), DXC \cs_6_0\ dispatch readback on WARP and \AMD Radeon RX 7900 XTX\ (debug layer enabled) on a loop/straight \execz\ break-without-exit variant, plus \LOOP_BREAK_WORDS\ still keeping its \T2\ refusal while dropping the \T1\ \exec write\ refusal. AI-assisted.
Not-Saii commented 2026-11-26 16:51:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T16:51:16Z.


Question before claiming T3, with a T3 claim that depends on the answer

#2852 took T2's "keep it refused with its own reason" option (loop exit crosses a backward s_cbranch_scc0), so I'm leaving T2 alone. T3 and T4 both relax conditions of the "lane mask
exhausted" exit proof, which the issue body places on a local branch stacked on #2557. At b505c32b
that proof is not on main: Stage.execz_refusals refuses every branch whose target lies outside
the skipped block and its join, as branch out of the block. RonLogic's skeleton with the latch
removed gets that refusal, and check_execz_loop_break pins it.

@NiiRoZz, do you plan to open the exit proof as a PR? If you do, I'll stack T3 on it. If not, I can
land the straight form of it (no backward branch between the join and the exit target, so #2852's
refusal stays) together with T3, as one PR.

Payoff: all 26 programs in the body contain the latch, so T3 or T4 alone translates none of them.
triggered02's census has no s_cbranch_scc0 row, so it can't rank T3 against T4. I picked T3 because
RonLogic's skeleton covers it.

Claim, depending on the answer above: T3 (an exit target that is a scalar run before the exec
rewrite)
, in tools/startup/gfx2hlsl.py (Stage.execz_refusals).

Scope:

  • Only the branch-out arm of execz_refusals. For an accepted exit whose target starts with
    instructions other than the move into exec (s_mov_b32 exec_lo, sS or s_mov_b64 exec, s[a:b]),
    accept a straight run of them when each one is a scalar ALU, s_load or s_waitcnt instruction
    with no effect outside scalar registers (EXECZ_REFUSED), and reads neither exec nor a word that
    anything between the exit branch and the target may write. The wave and the model can hold
    different values in those words at the target. Vector instructions and branches in the run stay
    refused.
  • Unchanged: #2852's T2 refusal, T1's subset facts, T4's live mask, execz_live_read and the
    if-conversion mask rules.

How it fits with T1 (#2877): #2877 changes the entry seed, adds the pre_sub dataflow and changes
the exec write condition. T3 touches only the branch-out arm. The accepted case needs T1 to prove
s_mov_b32 exec_lo, s22 on the path that stays, so I'll rebase on #2877 after it merges. Its exact
LOOP_BREAK_WORDS assertion (only +0x30, loop exit crosses a backward s_cbranch_scc0) stays as
it is.

Fixture (tests/startup_gfx2hlsl_compute_check.py, case O state, 8×1×1, built only from encodings
already in the check and confirmed with the repository decoder):

  • Accepted: RonLogic's skeleton with the latch removed, so the pin at check_execz_loop_break moves
    from refused to accepted. The wave stays, and wave and per-lane traces agree on
    [9, 1, 1, 9, 9, 9, 9, 9]. A second variant starts the counter at 3, so every lane breaks and the
    wave takes the exit. It is checked the same way.
  • Near misses, each refused, each with the wave and lane trace disagreement shown in the check:
    1. A run instruction reads a word written between the branch and the target: the descriptor
      base comes from the counter s24, which the wave and the exiting lane hold at different values.
    2. A vector instruction in the run before the exec move (v_mov_b32 v5, s24): the exiting lane
      runs it with its exec bit set and the wave with that bit clear (lane 0: model 1, wave 9).
    3. No exec move at the end of the run.
  • Revert control: with the change reverted, the accepted case is refused again as branch out of the block.

Verification: python -B tests/startup_gfx2hlsl_compute_check.py and
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_' on Windows. That covers the
first diagnostic of each negative, plus WARP and one short hardware readback of the accepted case's
first eight words, reported with adapter, driver, Windows build, commit and debug-layer status.
binary llvm-mc-15 and decode modes won't run here (no llvm-mc). They'll be listed as not run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7198180382 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7198180382). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T16:51:16Z. --- **Question before claiming T3, with a T3 claim that depends on the answer** #2852 took T2's "keep it refused with its own reason" option (`loop exit crosses a backward s_cbranch_scc0`), so I'm leaving T2 alone. T3 and T4 both relax conditions of the "lane mask exhausted" exit proof, which the issue body places on a local branch stacked on #2557. At `b505c32b` that proof is not on main: `Stage.execz_refusals` refuses every branch whose target lies outside the skipped block and its join, as `branch out of the block`. RonLogic's skeleton with the latch removed gets that refusal, and `check_execz_loop_break` pins it. @NiiRoZz, do you plan to open the exit proof as a PR? If you do, I'll stack T3 on it. If not, I can land the straight form of it (no backward branch between the join and the exit target, so #2852's refusal stays) together with T3, as one PR. Payoff: all 26 programs in the body contain the latch, so T3 or T4 alone translates none of them. triggered02's census has no `s_cbranch_scc0` row, so it can't rank T3 against T4. I picked T3 because RonLogic's skeleton covers it. **Claim, depending on the answer above: T3 (an exit target that is a scalar run before the exec rewrite)**, in `tools/startup/gfx2hlsl.py` (`Stage.execz_refusals`). Scope: - Only the branch-out arm of `execz_refusals`. For an accepted exit whose target starts with instructions other than the move into exec (`s_mov_b32 exec_lo, sS` or `s_mov_b64 exec, s[a:b]`), accept a straight run of them when each one is a scalar ALU, `s_load` or `s_waitcnt` instruction with no effect outside scalar registers (`EXECZ_REFUSED`), and reads neither exec nor a word that anything between the exit branch and the target may write. The wave and the model can hold different values in those words at the target. Vector instructions and branches in the run stay refused. - Unchanged: #2852's T2 refusal, T1's subset facts, T4's live mask, `execz_live_read` and the if-conversion mask rules. How it fits with T1 (#2877): #2877 changes the entry seed, adds the `pre_sub` dataflow and changes the `exec write` condition. T3 touches only the branch-out arm. The accepted case needs T1 to prove `s_mov_b32 exec_lo, s22` on the path that stays, so I'll rebase on #2877 after it merges. Its exact `LOOP_BREAK_WORDS` assertion (only `+0x30`, `loop exit crosses a backward s_cbranch_scc0`) stays as it is. Fixture (`tests/startup_gfx2hlsl_compute_check.py`, case O state, 8×1×1, built only from encodings already in the check and confirmed with the repository decoder): - Accepted: RonLogic's skeleton with the latch removed, so the pin at `check_execz_loop_break` moves from refused to accepted. The wave stays, and wave and per-lane traces agree on `[9, 1, 1, 9, 9, 9, 9, 9]`. A second variant starts the counter at 3, so every lane breaks and the wave takes the exit. It is checked the same way. - Near misses, each refused, each with the wave and lane trace disagreement shown in the check: 1. A run instruction reads a word written between the branch and the target: the descriptor base comes from the counter `s24`, which the wave and the exiting lane hold at different values. 2. A vector instruction in the run before the exec move (`v_mov_b32 v5, s24`): the exiting lane runs it with its exec bit set and the wave with that bit clear (lane 0: model 1, wave 9). 3. No exec move at the end of the run. - Revert control: with the change reverted, the accepted case is refused again as `branch out of the block`. Verification: `python -B tests/startup_gfx2hlsl_compute_check.py` and `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'` on Windows. That covers the first diagnostic of each negative, plus WARP and one short hardware readback of the accepted case's first eight words, reported with adapter, driver, Windows build, commit and debug-layer status. `binary llvm-mc-15` and decode modes won't run here (no `llvm-mc`). They'll be listed as not run. AI-assisted (Claude Code).
Not-Saii commented 2026-11-26 18:14:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T18:14:11Z.


#2900 (brainbudt, opened 17:29Z) does T3 together with the straight lane-exhaustion exit proof. That is the second option in my comment above, so I'm withdrawing my conditional T3 claim to avoid duplicate work. The question above about the exit proof on the local branch still stands, since #2900 now adds a version of it.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7200213679 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7200213679). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T18:14:11Z. --- #2900 (brainbudt, opened 17:29Z) does T3 together with the straight lane-exhaustion exit proof. That is the second option in my comment above, so I'm withdrawing my conditional T3 claim to avoid duplicate work. The question above about the exit proof on the local branch still stands, since #2900 now adds a version of it. AI-assisted (Claude Code).
SimSalabimse commented 2026-11-27 10:23:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-27T10:23:51Z.


Claiming T4 (an accumulated lane mask live at the exit target) in tools/startup/gfx2hlsl.py (Stage.execz_refusals / Stage.execz_scalar_exit).

Base: #2900 at 022212aa. On main at 98007de5 the lane-exhaustion exit is absent: a branch out of a block s_cbranch_execz skips is refused as branch out of the block, or as loop exit crosses a backward s_cbranch_scc0 when it jumps over a backward latch. T4 relaxes a condition of the straight exit proof, so this work is stacked on #2900. #2877 is a separate line and is not part of this base. The straight fixture uses the single saved mask that proof already accepts.

Scope:

  • In the straight span after s_mov_b32 exec_lo, mask and before the exit target, accept s_and_b32 sA, sA, exec_lo followed by s_or_b32 sB, sB, sA. The exit branch jumps over the pair. A lane that leaves skips it; the wave runs it with that lane's exec bit clear, so the lane's own bit of sB is unchanged. sA must be dead at the exit target: the wave clears a leaving lane's bit and the one-lane model does not.
  • Every later read of sB, until sB is rewritten, must be per lane (Stage.per_lane_read: v_cndmask, carry-in, s_and_saveexec_b32, s_and_b32 with exec), the same reads as the if-conversion mask.
  • Unchanged: the backward-latch refusal, the scalar run before the exec restore, the 32-thread bound, and the if-conversion mask rules. The counted loop in the issue still carries the latch and the second mask, so this task on its own translates none of those programs.

Fixture (tests/startup_gfx2hlsl_compute_check.py, case O state, built from the straight exit fixture):

  • Accepted: the straight exit with s_and_b32 sA, sA, exec_lo; s_or_b32 sB, sB, sA between the staying remask and the exit, sB live and read per lane. Wave and singleton traces agree. A second group in which every lane leaves is checked the same way; the wave skips the pair too.
  • Near misses, each refused as branch out of the block, each with the wave and singleton disagreement shown in the check:
    1. A later read of sB that is not per lane.
    2. A write that mixes another word's bits (s_or_b32 sB, sB, sC where sC is not the exec-masked sA, or s_and_b32 whose other source is not exec_lo).
    3. A later read of sA when that lane's bit of sA was 1.
  • Revert control: with the change reverted, the accepted case is refused again as branch out of the block.

Verification: python -B tests/startup_gfx2hlsl_compute_check.py, and that check under llvm-mc-15 when the assembler is present; tools/run_checks_parallel.py -j 4 --from-dir tests/checks/python-linux. On a Windows test PC (RTX 4070 Ti): ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'. D3D12 readback is not part of the host result.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7215835681 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7215835681). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-27T10:23:51Z. --- Claiming T4 (an accumulated lane mask live at the exit target) in `tools/startup/gfx2hlsl.py` (`Stage.execz_refusals` / `Stage.execz_scalar_exit`). **Base:** #2900 at `022212aa`. On `main` at `98007de5` the lane-exhaustion exit is absent: a branch out of a block `s_cbranch_execz` skips is refused as `branch out of the block`, or as `loop exit crosses a backward s_cbranch_scc0` when it jumps over a backward latch. T4 relaxes a condition of the straight exit proof, so this work is stacked on #2900. #2877 is a separate line and is not part of this base. The straight fixture uses the single saved mask that proof already accepts. **Scope:** - In the straight span after `s_mov_b32 exec_lo, mask` and before the exit target, accept `s_and_b32 sA, sA, exec_lo` followed by `s_or_b32 sB, sB, sA`. The exit branch jumps over the pair. A lane that leaves skips it; the wave runs it with that lane's exec bit clear, so the lane's own bit of `sB` is unchanged. `sA` must be dead at the exit target: the wave clears a leaving lane's bit and the one-lane model does not. - Every later read of `sB`, until `sB` is rewritten, must be per lane (`Stage.per_lane_read`: `v_cndmask`, carry-in, `s_and_saveexec_b32`, `s_and_b32` with exec), the same reads as the if-conversion mask. - Unchanged: the backward-latch refusal, the scalar run before the exec restore, the 32-thread bound, and the if-conversion mask rules. The counted loop in the issue still carries the latch and the second mask, so this task on its own translates none of those programs. **Fixture** (`tests/startup_gfx2hlsl_compute_check.py`, case O state, built from the straight exit fixture): - Accepted: the straight exit with `s_and_b32 sA, sA, exec_lo; s_or_b32 sB, sB, sA` between the staying remask and the exit, `sB` live and read per lane. Wave and singleton traces agree. A second group in which every lane leaves is checked the same way; the wave skips the pair too. - Near misses, each refused as `branch out of the block`, each with the wave and singleton disagreement shown in the check: 1. A later read of `sB` that is not per lane. 2. A write that mixes another word's bits (`s_or_b32 sB, sB, sC` where `sC` is not the exec-masked `sA`, or `s_and_b32` whose other source is not `exec_lo`). 3. A later read of `sA` when that lane's bit of `sA` was 1. - Revert control: with the change reverted, the accepted case is refused again as `branch out of the block`. **Verification:** `python -B tests/startup_gfx2hlsl_compute_check.py`, and that check under `llvm-mc-15` when the assembler is present; `tools/run_checks_parallel.py -j 4 --from-dir tests/checks/python-linux`. On a Windows test PC (RTX 4070 Ti): `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'`. D3D12 readback is not part of the host result. AI-Assisted
Leyukaka commented 2026-11-29 20:38:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T20:38:16Z.


I'm working on the <op> inside a block s_cbranch_execz skips per lane: definition of <regs>, live where the block joins[: read by <op> after the join] refusal (tools/startup/gfx2hlsl.py:3339/:3342, Stage.execz_refusals, main 5b86df1d), as a new task here. It is a different branch from branch out of the block (execz_scalar_exit), which is all #3109 changes. In one long local run of the application it is among the most frequent first refusals of compute shaders requested late in the run.

Plan: accept more live definitions where every read from the join on is proven: words phi_mask_ok skips because the block is not straight, and reads execz_live_read rejects (word not kept through s_andn2, or EXEC no longer unchanged since the join). Everything else stays refused with the same text.
Tests: one accepted and one refused control per form, each checked by mutation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7262239422 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7262239422). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T20:38:16Z. --- I'm working on the `<op> inside a block s_cbranch_execz skips per lane: definition of <regs>, live where the block joins[: read by <op> after the join]` refusal (`tools/startup/gfx2hlsl.py:3339`/`:3342`, `Stage.execz_refusals`, main `5b86df1d`), as a new task here. It is a different branch from `branch out of the block` (`execz_scalar_exit`), which is all #3109 changes. In one long local run of the application it is among the most frequent first refusals of compute shaders requested late in the run. Plan: accept more live definitions where every read from the join on is proven: words `phi_mask_ok` skips because the block is not straight, and reads `execz_live_read` rejects (word not kept through `s_andn2`, or EXEC no longer unchanged since the join). Everything else stays refused with the same text. Tests: one accepted and one refused control per form, each checked by mutation.
Leyukaka commented 2026-11-29 20:44:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T20:44:43Z.


Releasing my claim above on the live where the block joins execz refusal in tools/startup/gfx2hlsl.py; nothing was pushed. Since #3449 default runs set X2W_NATIVE_SHADERS_ONLY=1, and load_translation / load_compute_translation then return before reading <key>.txt, so a Python lowering no longer changes what a default run of the application executes. I'll look at the native frontend's refusals instead.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7262323739 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2645#issuecomment-7262323739). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T20:44:43Z. --- Releasing my claim above on the `live where the block joins` execz refusal in `tools/startup/gfx2hlsl.py`; nothing was pushed. Since #3449 default runs set `X2W_NATIVE_SHADERS_ONLY=1`, and `load_translation` / `load_compute_translation` then return before reading `<key>.txt`, so a Python lowering no longer changes what a default run of the application executes. I'll look at the native frontend's refusals instead.
Sign in to join this conversation.
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#2637
No description provided.