shader: lower a forward SCC if/else diamond over vector ALU in pixel_aot #1618
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1625"
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 MasterDomino on 2026-11-24T15:14:41Z.
Refs #1413 (stage 2)
pixel_aotnow lowers a single structured forward SCC if/else diamond over vector ALU, on top of #1440, as approved on #1413.Behaviour (
tools/pixel_aot.py)s_branch, the branch opens a diamond. Thes_branchmust land on JOIN, a later boundary after B's first instruction, decoded the same way as the conditional target. A conditional edge that lands elsewhere is refused by the stage-1 rules: onto thes_branch, thes_branchthen runs outside any block; onto JOIN, thes_branchsits inside the skipped block.s_cmp/s_bitcmpSCC. Block A runs under the stage-1 condition (sccforscc0,!sccforscc1) and block B under its negation.s_branch, the region switches to B through the else-arm state from #1371:Else arm reads a register defined only in the then arm);condition ? A : B, with the incoming value standing in for a block that did not write it. A register undefined on entry and not written by both blocks stays undefined after JOIN.Tests
check_scc_diamond_controls:sample16.z.s_branch; conditional edge onto JOIN;s_branchonto B's first instruction, backward, or outside the program; ans_branchthat is not last in A.check_scc_diamond_draw, run by the existingpixel_aot_scc_skip_{warp,hardware}:s_cmp_eq_u32 s47, 0+s_cbranch_scc1, ands_cmp_lg_u32 s47, 0+s_cbranch_scc0.s_branch(flag 1, so A falls through into B), and the correct shader against a stale-A expectation where B reads A's v14 (flag 0)..Lscc_elseand.Lscc_joinlabels.tests/form_coverage_check.py:s_branchis now recorded as an accepted form. The check used it as its example of a form that only reaches rejections; it now assertss_branchis accepted, keepss_code_endas the not-accepted example, and adds("SOPP", "s_branch")to the covered SCC-branch forms.Results
117ebb8bon71be6f0f. Windows 11 26H2 (build 26300.9974),devpreset, DXC 1.8.2502.11, Python 3.13.1, LLVM 15.0.7.WARP
10.0.26100.9818: the 6 diamond cases (2 forms × flag 0/1/7) match at 64/64 pixels. All 8 mutant cases mismatch: 2 stale-A, 4 polarity, 2 dropped-branch. The stage-1 skip cases still pass.AMD Radeon RX 9070 XT, driver
32.0.31044.16: the 6 diamond cases match. All 8 mutant cases mismatch. The stage-1 skip cases still pass.All 37 pure-Python checks listed in
AGENTS.mdpass.Negative control: with
tools/pixel_aot.pyrestored to main,check_scc_diamond_controlsfails withInstruction cannot run in a uniform skip block: s_branch 2.Not measured
The #1413 counts are shapes only: 9,004 diamond branches in 3,201 records. The number of local records this unblocks is not measurable while the scan's translator verdict stops at unbound operands (#1314). The draws pin the translator's model on desktop adapters; they are not evidence for gfx1013 hardware.
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:45:10Z.
Review: COMMENTED
Technical review (Linux only; no Windows, WARP or GPU run). The draw results in
docs/experiments.md(six cases, eight mutant cases on WARP and a hardware adapter) are therefore not reproduced here.Checked out the PR head in a clean tree.
What I ran:
tests/pixel_aot_check.py(default controls, includes the newcheck_scc_diamond_controls): passes.tests/form_coverage_check.py: passes with the updateds_branchexpectation.llvm-mc-19/llvm-objcopy-19for gfx1013 and disassembled with LLVM 19: the translation of the real machine bytes (scc_diamond_asm, with labels) equals the translation of the hand-offset fixture, for botheq/scc1andlg/scc0. (pixel_aot_check.py binaryas a whole stops earlier with LLVM 19 incheck_f16_cvt_int16_binary, code this PR does not touch, so I ran the scc fixtures separately.)scc_diamond(): A writes then reads its own value, B reading a register A wrote with an incoming value, a register written by both arms and read after JOIN, one written by A only. All merge ascond ? A : Bwith the incoming value standing in for an arm that did not write it, and B reads the incoming value, not A's. Av_cmpwriting VCC in either arm is refused.cond= SCC forscc0and!SCCforscc1, matching the merge order;join <= endrejects a JOIN on B's first instruction and backward targets; the skip path is unchanged.Local mutation check on
tools/pixel_aot.py(each reverted afterwards; tree clean), running the Linux controls (check_scc_diamond_controlsandcheck_scc_skip_controls):join <= endweakened tojoin < end, or the join check removed: caught.else_undefinednot recorded: caught.s_branchmatch widened to any branch, or the JOIN offset computed without the+ 4: caught.region["then"] = {dst: region["written"][dst] ...}): not caught. The translation changes for the worse (for examplev13becomes(!scc) ? sample16.y : ...andv14becomes(!scc) ? sample16.z : sample16.z, i.e. A's writes are lost), but the Linux controls only assert that_v13,_v14and_v15merge lines exist and that B contains(0.5f * sample16.z). Only the Windows draw would see it.-0x8000 <= jimm <= 0x7fffrange test removed: not caught (cosmetic; the decoder only yields a 16-bit immediate).Suggestion (non-blocking): in
check_scc_diamond_controls, assert the full merge expressions for the default diamond, for examplealu27_v13 = ((!scc20) ? alu22 : alu25)forscc1(or build the strings from the A and B operands), so the A arm is pinned without a Windows machine. As written, the Linux-visible controls would still pass if the lowering dropped A's results.Nothing else found. No conflict with other open work in
tools/pixel_aot.pyseen in the diff.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:55:56Z.
Resolved the conflict with #1527 in
7355cc6e. The diamond controls are registered in the same table for serial and parallel runs, and the Windows form coverage check plus RTX and WARP SCC draws passed.