Repository navigation
agx: keep the values a fused break leaves with live - #575
DjDeveloperr wants to merge 1 commit into
Conversation
agx_opt_break_if moves a conditional break into the block after its if, but the edge to the break target stays on the emptied then block. Post-RA liveness therefore did not see what the loop exit reads at the break, and a value read at the exit but last read in the loop by the break's own compare got a last-use hint there. On AGX3 a last-use hint releases the register, so every thread taking the break could then read a released register at the loop exit. Take the break target's live-in as live at the break itself. A break's block is not a predecessor of its target, so with fused breaks the analysis repeats until nothing changes. Only hints that were wrong go away. Found while reviewing the G17P last-use change that follows. Signed-off-by: Diljit Singh <hey@djdev.me>
|
Local equivalent of the asahi CI job on f28285a (no CI run has started on this PR yet): host aarch64 clang release build with |
|
No blockers. What I checked at f28285a. PR body: the last line is the "Generated with Claude Code" banner rather than HW row: Neo (G17P), one other AGX3 Mac (J616s) and one M1 or M2 (the pass runs on AGX2 too) on aurora-wip with this commit: Assisted-by: LLM (Claude:Opus 5.5) |
|
Superseded by #603 (merged into Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
Problem
agx_opt_break_ifturnsif_cmp x, y { break } pop_execinto abreak_if_*cmpat the start of the block after the if, but the CFG edge to the break target stays on the emptied then block. The post-RA liveness inagx_opt_register_cachefollows CFG edges only, so at the fused break it does not see what the loop exit reads.A value that the exit reads, and that the loop last reads in the break's own compare, therefore gets a last-use (discard) hint on that compare. On AGX3 a last-use hint releases the register (on G17P a wrong one is known to destroy the value; see the ballot fix in
README-g17p-ballot-source-live.md). Every thread that takes the break can then read a released register at the loop exit:Change
The break target's live-in is taken as live at the break instruction, in the analysis and where the hints are set. A fused break's block is not a predecessor of its target, so when a shader has fused breaks the worklist analysis repeats until nothing changes. The change only removes hints that were wrong. All chips.
Testing
RegisterCache.FusedBreakKeepsTheExitsValue(uniform loop, the fused break's compare operand read at the exit). On aurora-wip 82af196 without this change it fails (brk->src[0].discardis true); with it, it passes.agx_tests: 1200 passed, 1 skipped (host aarch64 release build with drm-shim).djdev/g17p-dynamic-caching, which carries this commit first). No hardware row yet: this fixes hints on code shapes CTS may not reach under load; the Neo CTS gate will run with the G17P series.🤖 Generated with Claude Code