Recompiler: pass and track explicit SRC_SCC in per-lane lowering #2833
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2833"
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 ivall/xcl. Originally posted by safesearch77 on 2026-11-26T16:33:06Z.
Pass and track explicit
SRC_SCC(253) scalar operands consistently across the per-lane and split-wave64 (WaveSize(32)) Direct DXIL recompiler (crates/xcl/src/gpu/recomp/{lane_masks.rs,lower.rs}).Previously, per-lane lowering had three interlocking gaps whenever an RDNA2 instruction read
SCCvia scalar source code253(src_scc) rather than an implicitOPR_SSRC_SPECIAL_SCCoperand:Lower::bridge(crates/xcl/src/gpu/recomp/lower.rs:1753) checkedoperand(true, "OPR_SSRC_SPECIAL_SCC"), omitting(Var::Scc, zext(s))fromIr::foreigninputs and skippingself.read_scc(b)whenever a bridged instruction (V_CVT_F32_U32 v, src_scc,S_BFE_U32,V_ADD_CO_CI_U32, SDWAsrc_scc, etc.) encoded253explicitly. In compute, split-wave64, and graphics modes (ComputeInit/setup_gfxpre-seedingVAR_SCC = 0),DxilIr::foreignsucceeded whileLwsilently read0(or a stale block-localVAR_SCCwritten by an earlier bridged instruction) instead of the liveVar::Scc; in kernel mode it failed with"it reads register 125 the per-lane form did not pass"unless masked by an earlier bridged instruction in the same block; and partial-blockSCCwrites read after reconvergence bypassed thestalecheck.lane_masks::reads_scc(lane_masks.rs:282) andlower::compute_scc_liveness(lower.rs:1188) only scanned primary encoding fields["SSRC0", "SSRC1", "SRC0", "SRC1", "SRC2", "SOFFSET"]. ForVariant::Sdwa(SRC0 = 0xF9), scalarsrc_sccis encoded in the SDWA extension dword (S0 == 1 && VSRC0 == 253orS1 == 1 && VSRC1 == 253), solane_masksmissed divergent mask-opSCCreads in!wave_branchesandcompute_scc_livenessmarkedscc_live_after = falseinwave_branches(including split-wave64 compute), causingmask_nonzero_sccto skip the whole-wave ballot and hardcodeSCC = false. Scanning raw primary fields without checkingd.ienc.operandsalso caused false positives on unused fields (e.g.SRC2 = 253on a 1-sourceENC_VOP3instruction orOPR_ATTRonV_INTERP_*).Lower::src64(lower.rs:785) andLower::src_bit(lower.rs:475) rejected code253("64-bit source code 253"/"mask source code 253") instead of zero-extendingSCC((zext(scc), 0)insrc64and(lane == 0) & sccinsrc_bit, matchingdxil/lower.rs:732andrecomp/emit.rs:840).Part of #1269
What is in it
crates/xcl/src/gpu/recomp/lane_masks.rs: makereads_sccpub(super), inspect SDWAS0/VSRC0andS1/VSRC1scalar sources viaemit::ext_encoding, and restrict primary-word253checks to active non-implicit input operands (excluding non-plainSRC0, relative-sourceS_MOVRELS_*/S_MOVRELSD_2_B32SSRC0, andOPR_ATTR/OPR_PARAM) (+24 / -5).crates/xcl/src/gpu/recomp/lower.rs: uselane_masks::reads_sccin bothLower::bridgeandcompute_scc_liveness, and handle source code253inLower::src_bitandLower::src64(+13 / -6).crates/xcl/src/gpu/recomp/lane_masks.rs(tests::sdwa_and_vop3_src_scc_reads_are_classified_accurately): verifies non-uniform mask-opSCCrejection for SDWAS0andS1src_scc, acceptance whenS0/S1are0(v253) or afterS_AND_SAVEEXEC_B64, and no false positive on unusedENC_VOP3SRC2 = 253(+48).crates/xcl/src/gpu/recomp/lower.rs(tests::explicit_src_scc_in_salu_valu_bridge_and_wave_liveness): CPU execution andIr::foreignverification across 64-bit SALU & per-lane mask ops (S_MOV_B64,S_CSELECT_B64,V_CNDMASK_B32,S_AND_B64), bridged explicitSRC_SCC(V_CVT_F32_U32,S_BFE_U32), partial-block staleSCCrefusal across reconvergence, and split-wave64compute_scc_livenesswhole-wave ballot preservation before SDWAsrc_scc(+161).Tested
x86_64-pc-windows-gnu:cargo check --offline --workspace --testsgave 0 errors and 0 new warnings (only the 3 pre-existing baseline warnings on8b957bec, none ingpu/).rustc --edition=2021 --testharness compilinggpu::{rdna2_spec, rdna2_xbox, rdna2}andgpu::recomp::{x64_masks, ssa, upper_lanes, lane_masks, lower}(with Windows D3D12/DXC runner plumbing stubbed; no lowering or analysis code modified):8b957bec: all 4red_green_scc_testsfail (0 passed; 4 failed:"unsupported V_CVT_F32_U32 (it reads register 125 the per-lane form did not pass)", missinglane_masksrefusal on SDWAS0=1, VSRC0=253,ballots == 0on split-wave64S_AND_SAVEEXEC_B64before SDWAsrc_scc, and"64-bit source code 253").f5a352c3:107 passed; 0 failed; 1 ignoredacross allrdna2,x64_masks,ssa,upper_lanes,lane_masks,lower, andred_green_scc_testsunit tests.Regression run
xcl-smokeblocks (8b957becandf5a352c3) must be attached from a Windows GPU retail run before marking ready for review.Not tested
cargo test --workspace -- --test-threads=4GPU execution suite (including D3D12 wave32 / split-wave64 / native wave64 dispatch and DXCdxcompiler.dllvalidation) and paired Windowsscripts/smoke.ps1retail runs. Prepared on a Linux CPU host without a Windows GPU or retail title.AI use
Lower::bridge,reads_scc/compute_scc_liveness, andsrc64/src_bitSRC_SCC(253) defects, implemented the fix and unit tests, ran the Linuxrustc --testRED-to-GREEN harness andx86_64-pc-windows-gnuworkspace checks, and drafted this PR description.Imported from ivall/xcl. Originally posted by Smokeyqdqd on 2026-11-26T17:06:42Z.
Independent parent/head comparison on Windows 11 build 26200, Ryzen 7 5800X, RTX 3060 12 GB (NVIDIA 610.88), rustc 1.100.0 MSVC, DXC 1.9.2602.17, debug.
With
XCL_ADAPTER=3060andXCL_DIRECT_DXIL=1, I rancargo test --offline --locked -p xcl --lib -- src_scc gpu_split_wave64_ gpu_scalar_loop_and_scc --test-threads=1 --nocaptureon each revision.8b957bec6f82495aec940944c6bf47faa02db590, with only the two new test hunks added: 8 passed, 2 failed, 0 ignored. The failures weresdwa_and_vop3_src_scc_reads_are_classified_accuratelyandexplicit_src_scc_in_salu_valu_bridge_and_wave_liveness.f5a352c3455bbc2bc0b1951f6e01636ddb311f0a: 10 passed, 0 failed, 0 ignored.Neither run printed
SKIPPED. Both new compiler tests distinguish the revisions. The scalar-loop GPU test and the six split-wave64 GPU regression tests passed on both. Scope was this filtered suite only.AI use: Codex (GPT-6.2 Astra) ran the tests, checked the logs and drafted the report.
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-26T17:17:24Z.
RX 9070 / Wine per-lane SCC check at
f5a352c3455bbc2bc0b1951f6e01636ddb311f0aagainst main8b957bec6f82495aec940944c6bf47faa02db590. Head executes 30 per-lane combinations refused by main in this fixture. Six combinations remain translation refusals. All executed matrix outputs matched the independent expected values.Tested
RX 9070 16 GB, RADV GFX1201 / Mesa
26.3.1-arch3.5(mesaandvulkan-radeonpackages3:26.3.1-5), Ryzen 7 7700, CachyOS7.3.0-5-cachyos, GE-Proton11-12 Wine 11.0 Staging with ntsync. Native d3d12/d3d12core/dxgi; vkd3d-proton8293130ebe370b1+, local assertions-disabled build; DXC/DXIL1.9.2602.17, Rust1.97.1, releasex86_64-pc-windows-gnu.Exact pinned source copies, with both new CPU test functions copied unchanged to main and an identical local
cfg(test)GPU fixture appended tolower_dxil.rsin both copies. All original source hashes reconstruct after removing the additions. No original assertion was changed. These were instrumented source copies, not clean Git checkouts.XCL_NETWORK=0,XCL_ADAPTER="AMD Radeon RX 9070",XCL_REQUIRE_GPU=wave64,XCL_DXC_THREADS=1,XCL_DIRECT_DXIL=1,XCL_PER_LANE=1,XCL_DIRECT_COMPACT=0, native DLL overrides and private enabled caches per process. The local fixture explicitly callslower_dxil::kernel,kernel_splitandcompute_with; it records refusals without automatic fallback. Each accepted shader was validated with DXC validator 1.9 before GPU submission.N=1andN=4: head 15 passed / 0 failed / 0 ignored, main 13/2/0 per invocation. Both new tests fail on main.gpu::recomp::lower_dxil::tests:::a_per_lane_compute_program_runs_on_the_gpu,split_wave64_dead_scc_skips_exchange_barrier,a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out,the_runtime_path_takes_the_split_form.The local fixture checks native Wave32, native Wave64 and split Wave64 using two hardware Wave32s. Kernel inputs cover zero-extended SCC in scalar/mask sources, true/false/true
V_CVT_F32_U32refresh, and SDWA S0/S1 SCC reads. Compute inputs additionally select the upper half withS_AND_SAVEEXEC_B64, restore EXEC, then consume SCC via SDWA. Empty-mask and overwritten-SCC controls check zero. In the native64/split64 upper-half cases, all 64 stored values equallane + 1; empty/overwritten controls equallane. Guard words remain intact.Three fresh processes per entry/revision, alternating revision order, gave identical per-case outcomes:
Main reports
64-bit source code 253in the native scalar/mask kernel cases; the bridged cases reportit reads register 125 the per-lane form did not pass. On head, the native32 combined scalar/mask program still refusesS_AND_B64withs126: a mask read as a number. Five native32 compute sequences still refuseS_AND_SAVEEXEC_B64withwrites EXEC, the same message as main. These sequences retain the B64 encoding in the native32 arm.The local collection tests assert on any refusal, so each reports 0 passed / 1 failed / 0 ignored on both revisions, despite the increased coverage on head. Refused cases were never submitted to the GPU. Across 20 final harness invocations there were 0 ignored and 0 capability skips. The matrix evaluated 648 records and performed 522 validated GPU dispatches. Independently recomputed 16,608 kernel lane values, 336 scalar values and 71,760 compute words, including guards: zero mismatches. All 72 HLSL/instruction control shader containers matched byte-for-byte between revisions; each emitted case repeated byte-identically across its three runs.
Not tested
Graphics entry points, every explicit SCC consumer/encoding, partial-launch EXEC, more than one compute group or logical wave per group in the local matrix, end-to-end fallback, full workspace suite, native Windows, other adapters, retail data,
scripts/smoke.ps1, FPS or compilation-time effects. No console-hardware oracle was used.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) audited the diff, wrote local test-only fixtures, ran the paired tests, independently verified raw outputs/source/executable hashes, and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:01:55Z.
Triage (#1607) – head
f5a352cNo open or merged PR makes the same change. Main reads
SRC_SCC(253) only inLower::src; this PR adds it tosrc_bit(only lane 0 can hold SCC) andsrc64(zext(scc), 0). It also makeslane_masks::reads_scclook at real input fields only, including SDWAS0/S1, and passesVar::Sccto bridged instructions that encode 253 explicitly.No problems found in the diff. Only the
PR descriptioncheck is red.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.