Commit Graph

14 Commits

Author SHA1 Message Date
8e5cf5aef1 fix(rdna2spirv): include END in out_pcs for trailing conditional branches
A conditional branch in the last basic block (no fallthrough block, so
len(raw_edges[b]) == 1) emits OpSelect(%cond, tgt, len(blocks)) and can
leave %pc at either tgt or cfg_structure.END.

Compute exact per-block out_pcs in rdna2spirv._block_out_pcs (matching
wave64_emulate_opt), pass it through capped_tree() into both
cfg_structure.structure() (so single-target fall-off-the-end blocks also
keep their dominated target guard) and unwrap_known_pc_guards(), and
pass compact_out_pcs into cfg_structure.structure() in wave64_emulate_opt.

Add unit and semantic regression tests covering both the loop back-edge
repro reported in review and the non-loop dominated-target variant.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-25 03:41:00 +02:00
0681b9d280 cfg_structure / rdna2spirv: unwrap tautological %pc guards in structured CFGs (ms_wave_info_s3 AMD LLPC crash)
cfg_structure.structure() wraps post-dominating join blocks after a diamond or loop in a ('guard', g, ...) node even when %pc == g is tautologically true on every incoming path. wave64_emulate_opt._unwrap_known_pc_guards already unwraps these guards for --wave64-emulate, which is why ms_wave_info_s3 passed on 32-wide NVIDIA GPUs while crashing with 0xC0000005 on native wave64 AMD RDNA2 Windows (driver 24.10.24, LLPC) where blk2's OpControlBarrier stayed trapped inside a conditional OpBranchConditional.

Move unwrap_known_pc_guards into tools/cfg_structure.py (reused by wave64_emulate_opt with zero duplication) and apply it in rdna2spirv.capped_tree() so both assemble() and needs_barrier_rounds() see post-dominating join blocks at top level.

SHADER-STRUCTURED-PC-UNWRAP

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-25 03:40:21 +02:00
4e3517479b test_cfg_structure: the split-graph walk reuses the cached branch choices
split_choose built a random.Random(f"{seed}/{block}/{visit}") for every branch of 1.6 million steps, the exact value branch_index already caches. Same choices, so the same 18228 structured graphs, 1772 irreducible, 1755 split and 12692 with loops; 42.1 s -> 20.9 s.
2026-11-23 02:57:33 +01:00
451f2477b6 Run test_depth() in the test_cfg_structure.py __main__ runner 2026-11-22 20:27:31 +01:00
92800c634f Merge pull request #1993 from Ayinaki
# Conflicts:
#	docs/design.md
2026-11-22 10:40:13 -05:00
a044f4e78b docs/tests: fix measured baseline depth figure for 2,000 diamonds (2,000, not 4,000) 2026-11-22 11:27:20 -04:00
3e38c98377 rdna2spirv: bound structured nesting depth with the dispatch-loop form
spirv-val's structured-control-flow checking cost grows roughly with the cube
of the nesting depth: over the 1.0.2.1 corpus the deepest block sits 118
constructs deep and about 85% of validation time is in modules nested 20 or
deeper. cfg_structure.depth() measures the tree and a module deeper than
MAX_STRUCTURED_DEPTH (16) is emitted in the existing flat dispatch-loop form
instead, which emits the same blocks and only changes the routing. Depth
5-12 shows no gain, hence the bound at 16.
2026-11-22 15:23:55 +00:00
a827ff9f96 cfg_structure: make structuring iterative and flatten dominated tail continuations
Avoid O(N) OpSelectionMerge nesting and Python RecursionError on long sequential diamond/loop chains (e.g. unrolled ScreenProbes compute shaders): hoist each guarded member's dominated tail continuation out of its enclosing guard (exact by strict dominance) and make cfg_structure.structure, cfg_structure.run, and rdna2spirv.assemble's structured emitter iterative.
2026-11-22 10:51:34 -04:00
04b36bf297 tests: restore standalone CFG structure summary (TEST-138) 2026-11-22 16:37:59 +10:00
40f01a9cf4 test_cfg_structure: end the random-graph test on its assertions
test_random_graphs returned the five counters it had already asserted two
lines above, so pytest reported the file's only warning:
PytestReturnNotNoneWarning: Expected None, but ... returned (18228, 1772,
12692, 1755, 17). tests/requirements.txt pins pytest 9.2.0, which still warns
but says the warning becomes an error in a future release, so the file would
turn the translator-tests job red without anyone touching it.

Drop the return. Under both pytest 8.3.5 (local) and the pinned 9.2.0 (clean
venv) the file passes 2/2 with no warnings.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 00:04:22 -06:00
a4e435fac2 Merge pull request #276 from eIBart0 2026-11-21 17:38:33 -05:00
a638c5acb9 Cache seeded choices in the CFG structure test 2026-11-21 23:30:58 +01:00
338ff3354b tests: verify closed-region node splitting on random irreducible CFGs and synthetic shaders 2026-11-21 19:05:14 -03:00
987e8471ee Fix RDNA2 wave masks and flat inputs
Preserve whole-wave mask operations, saved EXEC values and flat
pixel inputs when generating SPIR-V. Keep a dispatch-loop fallback
alongside structured control flow and share the descriptor probe.

Add reproducible GPU fixtures for these cases and exercise the
control-flow and mask analyses in CI.
2026-11-21 16:56:54 +02:00