Repository navigation
gfx2hlsl: prove lane-local compute readfirstlane waterfall bodies - #2694
Merged
R0Y00 merged 4 commits intoNov 26, 2026
Merged
Conversation
…c-waterfall-proof
3 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
This implements the numeric and fixed raw-buffer part of #2644 T1. A compute loop can use a lane-varying
v_readfirstlane_b32key when the next compare selects that key's lanes, the saved remaining mask is intact, ands_andn2_wrexec_b32pluss_cbranch_scc1closes the loop. The fixture covers groups of up to 32 threads for the low-word mask.Each active lane receives its own key on its one participating visit. The proof reuses the compute scalar effect sets, exit liveness and branch targets. It checks the mask copy, entry edges, loop-carried scalars, the straight-line body and the registers that can escape. The output SGPR is marked varying. Per-key byte offsets are supported in a fixed bound raw buffer. Per-key resource selection still requires T3's bound heap range. AMD describes the waterfall and the two WREXEC widths in RDNA 2 ISA §12.3, opcodes 58 and 71.
Verification
Both complete synthetic programs stop at
v_readfirstlane_b32 requires a proven uniform sourceon the parentf06646ba. The host and LLVM 15.0.7 reassembly modes pass on the candidate. They cover a store, a read of the actual active-mask rank, a changed saved mask, a different compare source, a second entry edge, an escaping scalar on one or all paths, loop-carried SGPR/SCC, a per-key descriptor and a group with 33 threads. Overwriting the escaping scalar on every path is a positive control.The independent host reference covers 1,215 input and active-mask combinations. An active-mask-rank body produced 495 counterexamples to singleton execution and has a named refusal here. The synthetic fixtures use no captured input.
The registered dispatch fixture passed on WARP, GeForce RTX 4060 and Intel UHD 770 at
4fe7a4a5. Each run checked active counts from zero to four, an arithmetic overflow case, fixed-buffer reads, and two deliberately wrong references. The affected fixture also retains its original uniform-source and mutation checks.I separately compiled both programs with an input-configurable mask. For each adapter, five key tuples crossed with all 16 four-lane masks gave 80 arithmetic and 80 fixed-buffer readbacks. All 480 outputs matched the independent reference over all 320 words. A separately compiled mutant used the same lane's key for everyone. On each adapter, its first mismatch was word 1 in both programs (arithmetic expected
0x30, got0x50; fixed buffer expected0x91, got0x119). All 97 selected host-side translator and documentation checks passed. Two neighboring graphics fixtures also passed in their actual WARP draw modes.The branch includes #2693, which lets the existing fixture accept the renderer's adapter-selection notice when testing a secondary GPU. Review the four waterfall files against that prerequisite.
The first Linux CI run failed only the scalar-table arity mutation count (37 of 40). I reproduced the same result on unmodified main at
e76f8acd. The three templates with dedicated refusals ares_bfm_b32,s_mul_hi_i32ands_mul_hi_u32. Windows and LLVM CI passed on that head. The upstream fix landed in #2659 atad1ad194. I merged main through8ad488af: the resulting head27de79c9passes both the scalar-table mutation suite and the host readfirstlane tests, including LLVM reassembly.Refs #2644 and #2274. AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).