fix(shader): identify compute loop exits that cross a backward SCC branch #2844
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2852"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by brainbudt on 2026-11-26T13:57:25Z.
Problem
The compute translator reports
branch out of the blockwhen an earlys_cbranch_scc0exits an EXEC-zero guarded block past a backwards_cbranch_scc0. The generic message makes this loop shape indistinguishable from an ordinary forward exit. Refs #2645, T2.Change
Report
loop exit crosses a backward s_cbranch_scc0when the exit jumps over a latch that branches back to the guard or earlier. Add a source-built, 112-byte gfx1013 fixture that reproduces the two-mask loop from the issue.The wave and singleton models agree on the original eight output words. Reading the scalar counter after restoring EXEC exposes the difference: the wave exits with
3for every lane, while the singleton counters are[1, 2, 3, 4, 4, 4, 4, 4].Scope
T2 explicitly permits a named refusal for this case. Covers the translator diagnostic, its controls and the experiment record. The fixture is refused before dispatch, so WARP readback does not apply.
Verification
python3 -B tests/startup_gfx2hlsl_compute_check.pypassed on macOS ARM64 (including after rebasing onto latestorigin/main). The base translator failed the new assertion withbranch out of the block; removing only the latch restored that generic refusal, and removing only the EXEC-zero guard allowed translation.python3 -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15passed on Linux x86-64 with LLVM 15.0.7; the fixture also reassembled byte-for-byte with LLVM 22 on macOS.python-linux(209/209) andpixel-binary(135/135) suites passed.Reviewed with mistral-loop: APPROVE (1 round,
mistral-large-4-0+deepseek-v4-1-flash-1017).Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:02:56Z.
Review: COMMENTED
Review of head
cfb172e6.Result: no blocking findings.
What the change does: it only picks a more specific refusal reason (
loop exit crosses a backward s_cbranch_scc0) for a case that was already refused withbranch out of the block. No shape that translated before is refused now, and no refused shape starts translating. The condition (latch between the join and the exit target, same opcode, target at or before the guard) matches the fixture in the issue.WARP readback: not applicable here, because the fixture is refused before any HLSL is emitted. The CPU model in the test (wave versus per-lane counters,
[1, 2, 3, 4, 4, 4, 4, 4]versus 3) is the reason a refusal is the right outcome rather than a lowering.Checked locally:
python3 -B tests/startup_gfx2hlsl_compute_check.pyrc 0python3 -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-19rc 0 (the 112-byte fixture reassembles byte for byte)python3 tests/docs_links_check.pyrc 0,python3 tests/bidi_controls_check.pyrc 0,git diff --check origin/main...HEADcleanNot covered: no real-GPU run (not available right now).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:03:52Z.
Win2025 WARP receipt for head
cfb172e6(2 commits behind main, no update needed). Python-only change: the PR's own check ran on Windows.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
cfb172e6ead4fa73d650ef7951a5b94d1b1ebb3c:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check startup_stream_consumer -- -j 2):1.75s(configure1.90s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check startup_stream_consumer -- -j 2):37.44s(configure1.87s)tests/startup_gfx2hlsl_compute_check.pyok (0.7s)sccache: 14/18 hits; wall52.6stested:
cfb172e6via fetch (pull/2852/head, no patch)Real-GPU run not available (RunPod stopped).
AI-assisted; commands listed were executed locally.