fix(shader): guard shared loop exit routing and preserve valid fallbacks #2471

Merged
Scramblrrrr merged 10 commits from upstream-pr/2471 into main 2026-10-11 21:24:03 +00:00
Scramblrrrr commented 2026-10-09 22:26:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-09T22:26:04Z.


What

Selections inside natural loops can repeatedly split shared exit joins until CFG shared merge splitting exceeded budget. Guarded shared-exit routing lets additional valid graphs structure while refusing fallback outputs that fail the construct checks. Shared nested continuations are privatized to keep their branches inside the enclosing construct.

This change is updated onto main a11c8f7f7, head 3943287d63. The topic diff contains only the control-flow implementation/header and synthetic ControlFlow/Structurizer tests. AlxcBTW's underlying #20/#24 work retains author credit; main's #2941 iteration-selection behavior is preserved. The overlapping three-line global-join fallback was removed after differential testing. AlxcBTW found it adds valid large-block cases to main alone, but later passes in this stack recover those cases; removing it changes some valid outputs. The separate shared-exit continue-join helper remains, so this does not supersede that entire helper.

Two synthetic regressions exercise the shared continuation and padded large-block case. The original local title capture passed an earlier guarded head with 35 additional blocks, zero instruction clones and zero routing variables; that historical result is not a fresh title replay on this head. Title code, assets and serialized captures remain local.

Tested

Validation (Windows 11 / MinGW GCC 15.2):

  • Guarded current-main implementation 1773c64b versus main 77bd928a: two complete 30,000-case differential runs, at 16 and 1000 words/block, with 6,883 / 6,633 formerly failing cases fixed, zero status regressions and zero new invariant failures.
  • Overlap-reduced 3dc6b73a versus 1773c64b: both complete 30,000-case comparisons have identical statuses and error text. The harness does not record output identity or isolate each case in a subprocess.
  • Historical end-to-end runs reported 92 / 90 construct warnings while all 780 emitted modules were externally valid. The local harness incorrectly used ordinary dominance for construct membership; SPIR-V structural dominance also includes declared merge/continue edges. A reduced example included post-loop blocks inside a loop-body selection. With independently recomputed structural dominance, the current-main rerun has 800 attempts, 780 emitted modules, all 780 externally Vulkan 1.3-valid, and zero construct, structured-branch or execution-equivalence warnings. The same corrected harness against old main 77bd928a detects 23 warned outputs in 100 attempts; external validation rejects 15 of its 25 emitted modules. These are synthetic inputs, not title captures.
  • Rebase onto a11c8f7f7 preserves the topic implementation/header and both test files from bb5756097. Main changed GraphBuilder and request serialization, so focused ControlFlow and Structurizer executables were freshly compiled/linked with the current-main shader library and the topic Structurizer override; both pass. A complete 30,000-case 16-word comparison and 500-case 1000-word comparison have identical statuses/error text to the previous topic head. The local fuzz harness does not hash output identity or isolate cases in subprocesses. Conventions and diff checks pass. No standalone whole-project build/suite or playable-game result is claimed on this head.

Independent validation, attributed to AlxcBTW's report: full-graph hashes and structured/post-dominator/original-target reachability checks on four 30,000-case seed-3 corpora plus 60,000 random reducible graphs found no invalid outputs or regressions for bb5756097. Small-block outputs match 1773c64b; some large-block outputs differ and remain valid. Their Windows median of three on 500 large-block graphs is 8.5 s for bb5756097 versus 27.9 s for a396b019. b0e6631f fired zero times in 210,000 runs on the guarded head and changed no outputs. These are their results, not additional local runs; the separate ordinary-dominance harness warnings have now been investigated and corrected locally as described above. Mouhand-Kaddo also reports three focused Linux CPU checks passing on bb5756097; no GPU/title result is claimed.
The guarded fallback still needs maintainer review; the former local end-to-end construct warnings came from the harness membership calculation and are no longer unexplained on these samples. Alxc's smaller b0e6631f early-refusal change was independently cross-tested on the previous a396b019 head with identical statuses/error text across both 30,000-case runs; it remains a separate alternative rather than being silently folded into this replacement.

Checklist

  • Based on current main a11c8f7f7; shader control-flow topic only

  • Underlying collaborator commits credited; #2941 behavior retained

  • Generic synthetic regressions; no title data or investigation artifacts

  • No new third-party dependencies; unsupported paths retain errors

  • Conventions and diff checks pass

  • AI-assisted: yes (Codex); author remains responsible for review

  • Depends on: none (the underlying current-main changes are already included in the base)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4806512462 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-09T22:26:04Z. --- ### What Selections inside natural loops can repeatedly split shared exit joins until `CFG shared merge splitting exceeded budget`. Guarded shared-exit routing lets additional valid graphs structure while refusing fallback outputs that fail the construct checks. Shared nested continuations are privatized to keep their branches inside the enclosing construct. This change is updated onto **main a11c8f7f7**, head **3943287d63f7fea8e45de0d76a62334f9f09069a**. The topic diff contains only the control-flow implementation/header and synthetic ControlFlow/Structurizer tests. AlxcBTW's underlying #20/#24 work retains author credit; main's #2941 iteration-selection behavior is preserved. The overlapping three-line global-join fallback was removed after differential testing. AlxcBTW found it adds valid large-block cases to main alone, but later passes in this stack recover those cases; removing it changes some valid outputs. The separate shared-exit continue-join helper remains, so this does not supersede that entire helper. Two synthetic regressions exercise the shared continuation and padded large-block case. The original local title capture passed an earlier guarded head with 35 additional blocks, zero instruction clones and zero routing variables; that historical result is not a fresh title replay on this head. Title code, assets and serialized captures remain local. ### Tested Validation (Windows 11 / MinGW GCC 15.2): - Guarded current-main implementation 1773c64b versus main 77bd928a: two complete 30,000-case differential runs, at 16 and 1000 words/block, with 6,883 / 6,633 formerly failing cases fixed, zero status regressions and zero new invariant failures. - Overlap-reduced 3dc6b73a versus 1773c64b: both complete 30,000-case comparisons have identical statuses and error text. The harness does not record output identity or isolate each case in a subprocess. - Historical end-to-end runs reported 92 / 90 construct warnings while all 780 emitted modules were externally valid. The local harness incorrectly used ordinary dominance for construct membership; SPIR-V structural dominance also includes declared merge/continue edges. A reduced example included post-loop blocks inside a loop-body selection. With independently recomputed structural dominance, the current-main rerun has 800 attempts, 780 emitted modules, all 780 externally Vulkan 1.3-valid, and zero construct, structured-branch or execution-equivalence warnings. The same corrected harness against old main 77bd928a detects 23 warned outputs in 100 attempts; external validation rejects 15 of its 25 emitted modules. These are synthetic inputs, not title captures. - Rebase onto a11c8f7f7 preserves the topic implementation/header and both test files from bb5756097. Main changed GraphBuilder and request serialization, so focused ControlFlow and Structurizer executables were freshly compiled/linked with the current-main shader library and the topic Structurizer override; both pass. A complete 30,000-case 16-word comparison and 500-case 1000-word comparison have identical statuses/error text to the previous topic head. The local fuzz harness does not hash output identity or isolate cases in subprocesses. Conventions and diff checks pass. No standalone whole-project build/suite or playable-game result is claimed on this head. Independent validation, attributed to [AlxcBTW's report](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6105093406): full-graph hashes and structured/post-dominator/original-target reachability checks on four 30,000-case seed-3 corpora plus 60,000 random reducible graphs found no invalid outputs or regressions for bb5756097. Small-block outputs match 1773c64b; some large-block outputs differ and remain valid. Their Windows median of three on 500 large-block graphs is 8.5 s for bb5756097 versus 27.9 s for a396b019. b0e6631f fired zero times in 210,000 runs on the guarded head and changed no outputs. These are their results, not additional local runs; the separate ordinary-dominance harness warnings have now been investigated and corrected locally as described above. Mouhand-Kaddo also reports three focused Linux CPU checks passing on bb5756097; no GPU/title result is claimed. The guarded fallback still needs maintainer review; the former local end-to-end construct warnings came from the harness membership calculation and are no longer unexplained on these samples. Alxc's smaller b0e6631f early-refusal change was independently cross-tested on the previous a396b019 head with identical statuses/error text across both 30,000-case runs; it remains a separate alternative rather than being silently folded into this replacement. ### Checklist - [x] Based on current main a11c8f7f7; shader control-flow topic only - [x] Underlying collaborator commits credited; #2941 behavior retained - [x] Generic synthetic regressions; no title data or investigation artifacts - [x] No new third-party dependencies; unsupported paths retain errors - [x] Conventions and diff checks pass - [x] AI-assisted: yes (Codex); author remains responsible for review - [x] Depends on: none (the underlying current-main changes are already included in the base)
github-actions[bot] commented 2026-10-09 22:53:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:53:48Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090637650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6090637650). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:53:48Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Mouhand-Kaddo commented 2026-10-10 10:04:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:04:56Z.


Additional platform validation on standalone PR head f088fb73646e2e5ee3924cfbdfb9736a350e2dd5:

Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja.

Release / BUILD_TESTING=ON: built the selected test targets; 3 CTest cases, 0 failures, 0 CTest skips.

Tests: agc_structurizer, agc_spirv_module, agc_shader_control_flow.

Reproduce after building the test targets: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_(shader_control_flow|structurizer|spirv_module)$".

Vulkan: Mesa lavapipe 26.2.4 software Vulkan; no native Linux GPU/retail-title validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096393013 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6096393013). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-10T10:04:56Z. --- <!-- anyps5-platform-validation:f088fb73646e2e5ee3924cfbdfb9736a350e2dd5 --> Additional platform validation on standalone PR head `f088fb73646e2e5ee3924cfbdfb9736a350e2dd5`: **Linux: passed** — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja. Release / `BUILD_TESTING=ON`: built the selected test targets; 3 CTest cases, 0 failures, 0 CTest skips. Tests: `agc_structurizer`, `agc_spirv_module`, `agc_shader_control_flow`. Reproduce after building the test targets: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_(shader_control_flow|structurizer|spirv_module)$"`. Vulkan: Mesa lavapipe 26.2.4 software Vulkan; no native Linux GPU/retail-title validation.
orishamir commented 2026-10-10 13:15:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T13:15:42Z.


Fuzzed this against main a29ef592 with random structured programs (30,000 graphs through Structurize, oracle = requireStructuredBranches from tests/Structurizer.cpp; samples through Recompile with SPIRV-Tools validation). Harness and commands: https://github.com/orishamir/anyps5-cfgfuzz.

  • 583 budget failures now structurize; 0 programs that structurize on main regress.
  • 1,425 budget failures become accepted outputs that break the structured-branch rule. Of 200 of those through Recompile: 60 valid, 104 Selection must be structured, 6 valid but failing verifyStructured, 24 still over budget, 6 refused. The rule flags 225 graphs on main already (#2762); with this PR 1,526.

Minimal case, budget on main, invalid SPIR-V here. In tests/Structurizer.cpp:

auto exitJunction = makeGraph({{1}, {2, 3}, {9}, {4, 6}, {5, 9}, {1}, {7, 8}, {9}, {1}, {}});
Structurizer{}.Structurize(exitJunction);
requireStructuredBranches(exitJunction, "a loop exit junction shared by break conditionals");
// block 7 branches without a merge, and neither target is its loop's merge or continue

Structurized with this PR (10 -> 13 blocks):

block 1   LOOP merge=6 continue=12
block 4   CondBranch(true=7 false=8)  merge=5    <- merge is the new empty exit block 5 (-> 6), the commonExit from findSelectionMerge
block 5   -> 6   (new)
block 7   CondBranch(true=9 false=5)  no merge   <- false arm goes to the junction 5, not to merge 6 or continue 12
block 8   CondBranch(true=10 false=11)  no merge <- 10 -> 5, 11 -> 12: same

SPIR-V allows a merge-less OpBranchConditional only as a direct break or continue, so conditionals whose arm reaches the junction need their own OpSelectionMerge, or the junction has to be the loop's merge block. Same shape as a wave64 compute shader through recompile() in tests/ControlFlow.cpp:

060202f2 060202f4 7d880084 bf870001 bf820011 060202ff 3f820000 7d880085 bf870005 060202ff 3f850000 7d880088 bf870009
bf82fff3 060202ff 3f840000 7d880087 bf870001 bf820003 060202ff 3f860000 bf82ffeb 060202f6 e0700000 80010100 bf810000

main: CFG shared merge splitting exceeded budget: originalBlocks=11 currentBlocks=55 splitBudget=44. This PR: SPIR-V validation before optimization failed: level=2 word=219: Selection must be structured OpBranchConditional %150 %31 %30.

Suggestion: run requireStructuredBranches on this PR's test graphs (verifyStructured in tests/ControlFlow.cpp does not check that rule), and only return commonExit when every conditional that branches to it directly has a merge.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097887214 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6097887214). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-10T13:15:42Z. --- Fuzzed this against `main` a29ef592 with random structured programs (30,000 graphs through `Structurize`, oracle = `requireStructuredBranches` from `tests/Structurizer.cpp`; samples through `Recompile` with SPIRV-Tools validation). Harness and commands: https://github.com/orishamir/anyps5-cfgfuzz. - 583 budget failures now structurize; 0 programs that structurize on `main` regress. - 1,425 budget failures become accepted outputs that break the structured-branch rule. Of 200 of those through `Recompile`: 60 valid, 104 `Selection must be structured`, 6 valid but failing `verifyStructured`, 24 still over budget, 6 refused. The rule flags 225 graphs on `main` already (#2762); with this PR 1,526. Minimal case, budget on `main`, invalid SPIR-V here. In `tests/Structurizer.cpp`: ```cpp auto exitJunction = makeGraph({{1}, {2, 3}, {9}, {4, 6}, {5, 9}, {1}, {7, 8}, {9}, {1}, {}}); Structurizer{}.Structurize(exitJunction); requireStructuredBranches(exitJunction, "a loop exit junction shared by break conditionals"); // block 7 branches without a merge, and neither target is its loop's merge or continue ``` Structurized with this PR (10 -> 13 blocks): ``` block 1 LOOP merge=6 continue=12 block 4 CondBranch(true=7 false=8) merge=5 <- merge is the new empty exit block 5 (-> 6), the commonExit from findSelectionMerge block 5 -> 6 (new) block 7 CondBranch(true=9 false=5) no merge <- false arm goes to the junction 5, not to merge 6 or continue 12 block 8 CondBranch(true=10 false=11) no merge <- 10 -> 5, 11 -> 12: same ``` SPIR-V allows a merge-less `OpBranchConditional` only as a direct break or continue, so conditionals whose arm reaches the junction need their own `OpSelectionMerge`, or the junction has to be the loop's merge block. Same shape as a wave64 compute shader through `recompile()` in `tests/ControlFlow.cpp`: ``` 060202f2 060202f4 7d880084 bf870001 bf820011 060202ff 3f820000 7d880085 bf870005 060202ff 3f850000 7d880088 bf870009 bf82fff3 060202ff 3f840000 7d880087 bf870001 bf820003 060202ff 3f860000 bf82ffeb 060202f6 e0700000 80010100 bf810000 ``` `main`: `CFG shared merge splitting exceeded budget: originalBlocks=11 currentBlocks=55 splitBudget=44`. This PR: `SPIR-V validation before optimization failed: level=2 word=219: Selection must be structured OpBranchConditional %150 %31 %30`. Suggestion: run `requireStructuredBranches` on this PR's test graphs (`verifyStructured` in `tests/ControlFlow.cpp` does not check that rule), and only return `commonExit` when every conditional that branches to it directly has a merge. AI-assisted: yes (Claude Code).
orishamir commented 2026-10-10 13:31:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T13:31:50Z.


One more data point, this time with large blocks. Real shaders reach privatizeSharedReturns only when a block's estimatedSpirvWords exceeds 256 (the test graphs with 0 words never do, as noted on #2642), so I reran the same 30,000 programs with 1,000 words per block and with one random 1,000-word block per program.

  • 1,000 words per block: this PR fixes 599 budget failures and regresses 2 programs that main structurizes (0 regressions with the fork fix from #2642 alone, in every configuration). One random large block: 589 fixed, 0 regressions.
  • Reduced regression, structurizer only, in tests/Structurizer.cpp (set the words like the sharedDiscard case does):
auto largeBlocks = makeGraph({{1}, {2, 3}, {1, 4}, {5, 6}, {1, 7}, {8, 7}, {9, 4}, {10}, {6, 10}, {10}, {}});
for (auto& block : largeBlocks.blocks) block.estimatedSpirvWords = 1000;
Structurizer{}.Structurize(largeBlocks);   // main: succeeds; this PR: CFG shared merge splitting exceeded budget: originalBlocks=13 currentBlocks=83 splitBudget=52

With 0 or 16 words per block both builds throw the budget error on this graph; from 300 words up main succeeds and this PR does not.

  • End to end: the same shape as a wave64 compute shader with 17 extra v_add_f32 per block (about 1,100 estimated words each) gives valid SPIR-V on main (1,888 words, 14 -> 48 blocks) and on the #2642 fix, and the budget error with this PR (originalBlocks=16 currentBlocks=102 splitBudget=64). Words below.
shader words (414 dwords)
060202f2 060202f0 060202ff 3f001000 060202ff 3f002000 060202ff 3f003000 060202ff 3f004000 060202ff 3f005000 060202ff
3f006000 060202ff 3f007000 060202ff 3f008000 060202ff 3f009000 060202ff 3f00a000 060202ff 3f00b000 060202ff 3f00c000
060202ff 3f00d000 060202ff 3f00e000 060202ff 3f00f000 060202ff 3f010000 060202f4 060202ff 3f000010 060202ff 3f001010
060202ff 3f002010 060202ff 3f003010 060202ff 3f004010 060202ff 3f005010 060202ff 3f006010 060202ff 3f007010 060202ff
3f008010 060202ff 3f009010 060202ff 3f00a010 060202ff 3f00b010 060202ff 3f00c010 060202ff 3f00d010 060202ff 3f00e010
060202ff 3f00f010 060202ff 3f010010 7d880084 bf870109 060202f6 060202ff 3f000030 060202ff 3f001030 060202ff 3f002030
060202ff 3f003030 060202ff 3f004030 060202ff 3f005030 060202ff 3f006030 060202ff 3f007030 060202ff 3f008030 060202ff
3f009030 060202ff 3f00a030 060202ff 3f00b030 060202ff 3f00c030 060202ff 3f00d030 060202ff 3f00e030 060202ff 3f00f030
060202ff 3f010030 7d880086 bf870096 060202ff 3f860000 060202ff 3f000060 060202ff 3f001060 060202ff 3f002060 060202ff
3f003060 060202ff 3f004060 060202ff 3f005060 060202ff 3f006060 060202ff 3f007060 060202ff 3f008060 060202ff 3f009060
060202ff 3f00a060 060202ff 3f00b060 060202ff 3f00c060 060202ff 3f00d060 060202ff 3f00e060 060202ff 3f00f060 060202ff
3f010060 7d880089 bf87004b 060202ff 3f840000 060202ff 3f000040 060202ff 3f001040 060202ff 3f002040 060202ff 3f003040
060202ff 3f004040 060202ff 3f005040 060202ff 3f006040 060202ff 3f007040 060202ff 3f008040 060202ff 3f009040 060202ff
3f00a040 060202ff 3f00b040 060202ff 3f00c040 060202ff 3f00d040 060202ff 3f00e040 060202ff 3f00f040 060202ff 3f010040
7d880087 bf87ff6a 060202ff 3f870000 060202ff 3f000070 060202ff 3f001070 060202ff 3f002070 060202ff 3f003070 060202ff
3f004070 060202ff 3f005070 060202ff 3f006070 060202ff 3f007070 060202ff 3f008070 060202ff 3f009070 060202ff 3f00a070
060202ff 3f00b070 060202ff 3f00c070 060202ff 3f00d070 060202ff 3f00e070 060202ff 3f00f070 060202ff 3f010070 bf82009a
060202ff 3f890000 060202ff 3f000090 060202ff 3f001090 060202ff 3f002090 060202ff 3f003090 060202ff 3f004090 060202ff
3f005090 060202ff 3f006090 060202ff 3f007090 060202ff 3f008090 060202ff 3f009090 060202ff 3f00a090 060202ff 3f00b090
060202ff 3f00c090 060202ff 3f00d090 060202ff 3f00e090 060202ff 3f00f090 060202ff 3f010090 bf820075 060202ff 3f850000
060202ff 3f000050 060202ff 3f001050 060202ff 3f002050 060202ff 3f003050 060202ff 3f004050 060202ff 3f005050 060202ff
3f006050 060202ff 3f007050 060202ff 3f008050 060202ff 3f009050 060202ff 3f00a050 060202ff 3f00b050 060202ff 3f00c050
060202ff 3f00d050 060202ff 3f00e050 060202ff 3f00f050 060202ff 3f010050 7d880088 bf870001 bf82ff8f 060202ff 3f880000
060202ff 3f000080 060202ff 3f001080 060202ff 3f002080 060202ff 3f003080 060202ff 3f004080 060202ff 3f005080 060202ff
3f006080 060202ff 3f007080 060202ff 3f008080 060202ff 3f009080 060202ff 3f00a080 060202ff 3f00b080 060202ff 3f00c080
060202ff 3f00d080 060202ff 3f00e080 060202ff 3f00f080 060202ff 3f010080 7d88008b bf87ff1d bf820027 060202ff 3f820000
060202ff 3f000020 060202ff 3f001020 060202ff 3f002020 060202ff 3f003020 060202ff 3f004020 060202ff 3f005020 060202ff
3f006020 060202ff 3f007020 060202ff 3f008020 060202ff 3f009020 060202ff 3f00a020 060202ff 3f00b020 060202ff 3f00c020
060202ff 3f00d020 060202ff 3f00e020 060202ff 3f00f020 060202ff 3f010020 7d880085 bf87feac bf82ff1b 060202ff 3f8a0000
060202ff 3f0000a0 060202ff 3f0010a0 060202ff 3f0020a0 060202ff 3f0030a0 060202ff 3f0040a0 060202ff 3f0050a0 060202ff
3f0060a0 060202ff 3f0070a0 060202ff 3f0080a0 060202ff 3f0090a0 060202ff 3f00a0a0 060202ff 3f00b0a0 060202ff 3f00c0a0
060202ff 3f00d0a0 060202ff 3f00e0a0 060202ff 3f00f0a0 060202ff 3f0100a0 e0700000 80010100 bf810000

Harness: https://github.com/orishamir/anyps5-cfgfuzz (run ... 1000 10 and run ... 16 10 1000, reduce2.py for the two-sided reduction, e2e/cfg2shader.py --pad 17). AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098020026 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6098020026). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-10T13:31:50Z. --- One more data point, this time with large blocks. Real shaders reach `privatizeSharedReturns` only when a block's `estimatedSpirvWords` exceeds 256 (the test graphs with 0 words never do, as noted on #2642), so I reran the same 30,000 programs with 1,000 words per block and with one random 1,000-word block per program. - 1,000 words per block: this PR fixes 599 budget failures and regresses 2 programs that `main` structurizes (0 regressions with the fork fix from #2642 alone, in every configuration). One random large block: 589 fixed, 0 regressions. - Reduced regression, structurizer only, in `tests/Structurizer.cpp` (set the words like the `sharedDiscard` case does): ```cpp auto largeBlocks = makeGraph({{1}, {2, 3}, {1, 4}, {5, 6}, {1, 7}, {8, 7}, {9, 4}, {10}, {6, 10}, {10}, {}}); for (auto& block : largeBlocks.blocks) block.estimatedSpirvWords = 1000; Structurizer{}.Structurize(largeBlocks); // main: succeeds; this PR: CFG shared merge splitting exceeded budget: originalBlocks=13 currentBlocks=83 splitBudget=52 ``` With 0 or 16 words per block both builds throw the budget error on this graph; from 300 words up `main` succeeds and this PR does not. - End to end: the same shape as a wave64 compute shader with 17 extra `v_add_f32` per block (about 1,100 estimated words each) gives valid SPIR-V on `main` (1,888 words, 14 -> 48 blocks) and on the #2642 fix, and the budget error with this PR (`originalBlocks=16 currentBlocks=102 splitBudget=64`). Words below. <details><summary>shader words (414 dwords)</summary> ``` 060202f2 060202f0 060202ff 3f001000 060202ff 3f002000 060202ff 3f003000 060202ff 3f004000 060202ff 3f005000 060202ff 3f006000 060202ff 3f007000 060202ff 3f008000 060202ff 3f009000 060202ff 3f00a000 060202ff 3f00b000 060202ff 3f00c000 060202ff 3f00d000 060202ff 3f00e000 060202ff 3f00f000 060202ff 3f010000 060202f4 060202ff 3f000010 060202ff 3f001010 060202ff 3f002010 060202ff 3f003010 060202ff 3f004010 060202ff 3f005010 060202ff 3f006010 060202ff 3f007010 060202ff 3f008010 060202ff 3f009010 060202ff 3f00a010 060202ff 3f00b010 060202ff 3f00c010 060202ff 3f00d010 060202ff 3f00e010 060202ff 3f00f010 060202ff 3f010010 7d880084 bf870109 060202f6 060202ff 3f000030 060202ff 3f001030 060202ff 3f002030 060202ff 3f003030 060202ff 3f004030 060202ff 3f005030 060202ff 3f006030 060202ff 3f007030 060202ff 3f008030 060202ff 3f009030 060202ff 3f00a030 060202ff 3f00b030 060202ff 3f00c030 060202ff 3f00d030 060202ff 3f00e030 060202ff 3f00f030 060202ff 3f010030 7d880086 bf870096 060202ff 3f860000 060202ff 3f000060 060202ff 3f001060 060202ff 3f002060 060202ff 3f003060 060202ff 3f004060 060202ff 3f005060 060202ff 3f006060 060202ff 3f007060 060202ff 3f008060 060202ff 3f009060 060202ff 3f00a060 060202ff 3f00b060 060202ff 3f00c060 060202ff 3f00d060 060202ff 3f00e060 060202ff 3f00f060 060202ff 3f010060 7d880089 bf87004b 060202ff 3f840000 060202ff 3f000040 060202ff 3f001040 060202ff 3f002040 060202ff 3f003040 060202ff 3f004040 060202ff 3f005040 060202ff 3f006040 060202ff 3f007040 060202ff 3f008040 060202ff 3f009040 060202ff 3f00a040 060202ff 3f00b040 060202ff 3f00c040 060202ff 3f00d040 060202ff 3f00e040 060202ff 3f00f040 060202ff 3f010040 7d880087 bf87ff6a 060202ff 3f870000 060202ff 3f000070 060202ff 3f001070 060202ff 3f002070 060202ff 3f003070 060202ff 3f004070 060202ff 3f005070 060202ff 3f006070 060202ff 3f007070 060202ff 3f008070 060202ff 3f009070 060202ff 3f00a070 060202ff 3f00b070 060202ff 3f00c070 060202ff 3f00d070 060202ff 3f00e070 060202ff 3f00f070 060202ff 3f010070 bf82009a 060202ff 3f890000 060202ff 3f000090 060202ff 3f001090 060202ff 3f002090 060202ff 3f003090 060202ff 3f004090 060202ff 3f005090 060202ff 3f006090 060202ff 3f007090 060202ff 3f008090 060202ff 3f009090 060202ff 3f00a090 060202ff 3f00b090 060202ff 3f00c090 060202ff 3f00d090 060202ff 3f00e090 060202ff 3f00f090 060202ff 3f010090 bf820075 060202ff 3f850000 060202ff 3f000050 060202ff 3f001050 060202ff 3f002050 060202ff 3f003050 060202ff 3f004050 060202ff 3f005050 060202ff 3f006050 060202ff 3f007050 060202ff 3f008050 060202ff 3f009050 060202ff 3f00a050 060202ff 3f00b050 060202ff 3f00c050 060202ff 3f00d050 060202ff 3f00e050 060202ff 3f00f050 060202ff 3f010050 7d880088 bf870001 bf82ff8f 060202ff 3f880000 060202ff 3f000080 060202ff 3f001080 060202ff 3f002080 060202ff 3f003080 060202ff 3f004080 060202ff 3f005080 060202ff 3f006080 060202ff 3f007080 060202ff 3f008080 060202ff 3f009080 060202ff 3f00a080 060202ff 3f00b080 060202ff 3f00c080 060202ff 3f00d080 060202ff 3f00e080 060202ff 3f00f080 060202ff 3f010080 7d88008b bf87ff1d bf820027 060202ff 3f820000 060202ff 3f000020 060202ff 3f001020 060202ff 3f002020 060202ff 3f003020 060202ff 3f004020 060202ff 3f005020 060202ff 3f006020 060202ff 3f007020 060202ff 3f008020 060202ff 3f009020 060202ff 3f00a020 060202ff 3f00b020 060202ff 3f00c020 060202ff 3f00d020 060202ff 3f00e020 060202ff 3f00f020 060202ff 3f010020 7d880085 bf87feac bf82ff1b 060202ff 3f8a0000 060202ff 3f0000a0 060202ff 3f0010a0 060202ff 3f0020a0 060202ff 3f0030a0 060202ff 3f0040a0 060202ff 3f0050a0 060202ff 3f0060a0 060202ff 3f0070a0 060202ff 3f0080a0 060202ff 3f0090a0 060202ff 3f00a0a0 060202ff 3f00b0a0 060202ff 3f00c0a0 060202ff 3f00d0a0 060202ff 3f00e0a0 060202ff 3f00f0a0 060202ff 3f0100a0 e0700000 80010100 bf810000 ``` </details> Harness: https://github.com/orishamir/anyps5-cfgfuzz (`run ... 1000 10` and `run ... 16 10 1000`, `reduce2.py` for the two-sided reduction, `e2e/cfg2shader.py --pad 17`). AI-assisted: yes (Claude Code).
Scramblrrrr commented 2026-10-10 17:37:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-10T17:37:21Z.


Thank you for the reduced cases and differential checks. I reproduced both on rebased head 470f51ce using Windows 11 / MinGW GCC 15.2.0:

  • The 10-block shared exit-junction graph returns output that fails requireStructuredBranches (a conditional without a merge whose targets are neither the loop merge nor continue).
  • The all-1,000-word reduced graph throws originalBlocks=13 currentBlocks=83 splitBudget=52.

These are confirmed gaps in this PR, not passing coverage from the existing tests. I am adding both regressions and repairing the merge selection/retry behavior, then will recheck the 007 stop-9 case and the existing structured-branch oracle before updating the branch. I will also cross-test AlxcBTW's #2642-related changes. Please keep this draft while that work is underway.

AI-assisted reproduction and investigation (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100334025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6100334025). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-10T17:37:21Z. --- Thank you for the reduced cases and differential checks. I reproduced both on rebased head **470f51ce** using Windows 11 / MinGW GCC 15.2.0: - The 10-block shared exit-junction graph returns output that fails `requireStructuredBranches` (a conditional without a merge whose targets are neither the loop merge nor continue). - The all-1,000-word reduced graph throws `originalBlocks=13 currentBlocks=83 splitBudget=52`. These are confirmed gaps in this PR, not passing coverage from the existing tests. I am adding both regressions and repairing the merge selection/retry behavior, then will recheck the 007 stop-9 case and the existing structured-branch oracle before updating the branch. I will also cross-test AlxcBTW's #2642-related changes. Please keep this draft while that work is underway. AI-assisted reproduction and investigation (Codex).
SleglJan commented 2026-10-10 22:12:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T22:12:31Z.


Linux cross-test of a396b019. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release.

Head a396b019 on main 262c0316, SPIRV-Tools on

  • Full suite: of 711 tests, 706 pass, 4 are skipped and 1 fails.
    • Passing: agc_structurizer, agc_shader_control_flow and agc_spirv_module.
    • Skipped: four video_out_flip_* tests, under ctest's offscreen SDL driver.
    • Failed: agc_driver_dcc_keys_first_write, a known failure on this machine (#2767) in the texture refresh path, which this PR doesn't touch.
  • #1921 shader. This is 007's captured request for the shader #1964 fixed, replayed with agc_shader_replay rebuilt at main and at each of the six commits. At every one of them it passes SPIR-V validation, then stops where main does: multisampled image resources have no descriptor image shape.

007 First Light on the #2523 stack, SPIRV-Tools off
The stack is 79dd488f with #2992 and the local commits from #2523. 78ad086b is cherry-picked on top; its ControlFlow/ is identical to a396b019's. One run with default asynchronous draws, compared with the same stack without 78ad086b:

  • All 2,194 shader variants compiled in the run prepare. None hits a structurizer budget.
  • Frames stop at the same queue-0 WAIT_REG_MEM_64 stall described in #2523, after frame 144 (168 without the commit). The lowest available memory is 27.2 GiB against 27.5 GiB, and peak RSS is 20.3 against 20.4 GiB, within run-to-run variation.
  • Four of 007's captured requests give identical agc_shader_replay output with and without 78ad086b. The build without it also lacks #2992, which the replay tool doesn't link. One of the four is #2523's stop-9 shader (125 blocks). All four get past the structurizer. Three then stop in runtime-source evaluation (SrtWalker::EvaluateRuntimeSources), and one stops at the multisampled descriptor shape (the #1921 shader above).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102729206 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6102729206). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T22:12:31Z. --- Linux cross-test of a396b019. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release. **Head a396b019 on `main` 262c0316, SPIRV-Tools on** - Full suite: of 711 tests, 706 pass, 4 are skipped and 1 fails. - Passing: `agc_structurizer`, `agc_shader_control_flow` and `agc_spirv_module`. - Skipped: four `video_out_flip_*` tests, under ctest's offscreen SDL driver. - Failed: `agc_driver_dcc_keys_first_write`, a known failure on this machine (#2767) in the texture refresh path, which this PR doesn't touch. - **#1921 shader.** This is 007's captured request for the shader #1964 fixed, replayed with `agc_shader_replay` rebuilt at `main` and at each of the six commits. At every one of them it passes SPIR-V validation, then stops where `main` does: `multisampled image resources have no descriptor image shape`. **007 First Light on the #2523 stack, SPIRV-Tools off** The stack is 79dd488f with #2992 and the local commits from #2523. 78ad086b is cherry-picked on top; its `ControlFlow/` is identical to a396b019's. One run with default asynchronous draws, compared with the same stack without 78ad086b: - All 2,194 shader variants compiled in the run prepare. None hits a structurizer budget. - Frames stop at the same queue-0 `WAIT_REG_MEM_64` stall described in #2523, after frame 144 (168 without the commit). The lowest available memory is 27.2 GiB against 27.5 GiB, and peak RSS is 20.3 against 20.4 GiB, within run-to-run variation. - Four of 007's captured requests give identical `agc_shader_replay` output with and without 78ad086b. The build without it also lacks #2992, which the replay tool doesn't link. One of the four is #2523's stop-9 shader (125 blocks). All four get past the structurizer. Three then stop in runtime-source evaluation (`SrtWalker::EvaluateRuntimeSources`), and one stops at the multisampled descriptor shape (the #1921 shader above). AI-assisted: yes (Claude Code)
orishamir commented 2026-10-10 22:51:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T22:51:05Z.


Where the compile-time cost on 78ad086b goes (the 3.5x from #2523): gprof plus an instrumented intersectSorted, the first 500 corpus3 graphs at 1,000 words per block, structurized in one process, 0b56b7ad as the baseline since the branch is that plus your commits.

  • Wall-clock 1.2 s -> 4.5 s, but by outcome: the 428 graphs both builds structurize take 157 ms vs 159 ms, the 42 this branch fixes 774 vs 786 ms, and the 30 that fail on both (budget/refused) 273 ms -> 3,566 ms. The whole slowdown is on graphs that end up rejected; successful structurizations cost what they did.
  • 8 of those 30 are 3.4 s of it: graph 79 (33 -> 966 ms, originalBlocks=21 currentBlocks=105 splitBudget=84), 449 (67 -> 763), 343 (9 -> 620), 383 (18 -> 373), 262 (22 -> 252), 14 (21 -> 235), 112 (19 -> 118), 264 (44 -> 102). Graph 79 as succ lists: 1;2,3;4;5;6,7;;8;1;9,10;11,12;4;13,8;10,14;15,16;17,18;5;19,10;5;8;12.
  • Hot path: 65% of the branch's time is intersectSorted called from computeDominatorTree. The tree is recomputed about as often as before (1.195M vs 1.185M calls over the 500 graphs, 96% from applyBlockOrder), but the sets it intersects are much larger: 8.9M intersections with the two inputs summing to 479 entries on average (max 1,464) against 2.4M summing to 50 (max 380). So on the failing graphs the fallback works on intermediate graphs of several hundred blocks before the budget stops it. The jump arrives with 78485b6d: 1.2 s on 0b56b7ad, 4.8 s on 78485b6d, 4.7 s on 0e4c5185, 4.5 s here.

Driver, scripts, both gprof profiles and the per-graph timings: https://github.com/orishamir/anyps5-cfgfuzz/tree/main/prof.

AI-assisted: yes (Claude Code Fable 5.1 xhigh)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103032944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6103032944). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-10T22:51:05Z. --- Where the compile-time cost on `78ad086b` goes (the 3.5x from #2523): gprof plus an instrumented `intersectSorted`, the first 500 corpus3 graphs at 1,000 words per block, structurized in one process, `0b56b7ad` as the baseline since the branch is that plus your commits. - Wall-clock 1.2 s -> 4.5 s, but by outcome: the 428 graphs both builds structurize take 157 ms vs 159 ms, the 42 this branch fixes 774 vs 786 ms, and the 30 that fail on both (budget/refused) 273 ms -> 3,566 ms. The whole slowdown is on graphs that end up rejected; successful structurizations cost what they did. - 8 of those 30 are 3.4 s of it: graph 79 (33 -> 966 ms, `originalBlocks=21 currentBlocks=105 splitBudget=84`), 449 (67 -> 763), 343 (9 -> 620), 383 (18 -> 373), 262 (22 -> 252), 14 (21 -> 235), 112 (19 -> 118), 264 (44 -> 102). Graph 79 as succ lists: `1;2,3;4;5;6,7;;8;1;9,10;11,12;4;13,8;10,14;15,16;17,18;5;19,10;5;8;12`. - Hot path: 65% of the branch's time is `intersectSorted` called from `computeDominatorTree`. The tree is recomputed about as often as before (1.195M vs 1.185M calls over the 500 graphs, 96% from `applyBlockOrder`), but the sets it intersects are much larger: 8.9M intersections with the two inputs summing to 479 entries on average (max 1,464) against 2.4M summing to 50 (max 380). So on the failing graphs the fallback works on intermediate graphs of several hundred blocks before the budget stops it. The jump arrives with `78485b6d`: 1.2 s on `0b56b7ad`, 4.8 s on `78485b6d`, 4.7 s on `0e4c5185`, 4.5 s here. Driver, scripts, both gprof profiles and the per-graph timings: https://github.com/orishamir/anyps5-cfgfuzz/tree/main/prof. AI-assisted: yes (Claude Code Fable 5.1 xhigh)
AlxcBTW commented 2026-10-11 01:02:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T01:02:24Z.


@Scramblrrrr @orishamir I traced the slowdown orishamir measured.

The fourth pass routes the same loop again and again. routeLoopExits sends each exit edge through an assignment block into a new junction, and that junction becomes the merge. A selection whose arms both reached a non-merge exit now reaches that assignment block with both arms, so hasSharedExitSelection picks the same loop again. canonicalizeNaturalLoops keeps routing it until the rewrite budget (2n+16) throws. Structurize then reports the second pass's error, so nothing shows in the result.

Graph 79 routes one loop 55 times and grows from 20 to 732 blocks. The new blocks are appended against flow order, so computeDominatorTree needs more sweeps every round, up to 332 for the last tree. Those are the large intersections in the profile. Across all 30,000 corpus3 graphs at 1,000 words, 1,410 route a loop again in that pass, and every one of them fails.

Fix: canonicalizeNaturalLoops throws when it would route the loop it routed in the previous rewrite. Once a loop is routed, only hasSharedExitSelection can pick it again, and routing it again just adds another junction layer of the same shape, so the pass can't end any other way. It's 7 lines, commit b0e6631f, directly on a396b019 and ready to cherry-pick.

Timings use orishamir's prof.cpp on the first 500 corpus3 graphs at 1,000 words. This was Windows, MinGW GCC 15.2 -O2, median of 3, so it's slower than his Linux numbers. Columns are 0b56b7ad / a396b019 / fix:

  • all 500: 6.9 s / 28.4 s / 7.2 s
  • the 30 that fail on all three: 1.46 / 22.5 / 1.52 s
  • graphs 79, 449, 343, 383, 262, 14, 112 and 264: 1.25 / 21.6 / 1.30 s; graph 79 alone: 138 / 5,915 / 162 ms
  • the 470 that a396b019 structurizes: 5.4 / 6.0 / 5.6 s. The fix doesn't touch their path.

The result is identical on every graph, meaning the same structurized graph or the same error. I checked all 30,000 corpus3 graphs at 0, 16, 100 and 1,000 words and at 16 with one 1,000-word block, plus 60,000 random reducible graphs. agc_structurizer, agc_shader_control_flow and agc_spirv_module pass, and so does the non-GPU suite (459/459).

#2471 no longer merges into main. Since #2941 landed, its iterationSelectionMerge conflicts with joinWithinIteration from my d692b963 in findSelectionMerge, so I couldn't run CI on the stack. That conflict is in my commit. I'm checking whether #2941 already covers d692b963's shape, and I'll post a rebased stack on current main with the same corpus comparison. The fix itself only touches canonicalizeNaturalLoops, which #2941 doesn't change.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104009588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104009588). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-11T01:02:24Z. --- @Scramblrrrr @orishamir I traced the slowdown orishamir measured. The fourth pass routes the same loop again and again. `routeLoopExits` sends each exit edge through an assignment block into a new junction, and that junction becomes the merge. A selection whose arms both reached a non-merge exit now reaches that assignment block with both arms, so `hasSharedExitSelection` picks the same loop again. `canonicalizeNaturalLoops` keeps routing it until the rewrite budget (2n+16) throws. `Structurize` then reports the second pass's error, so nothing shows in the result. Graph 79 routes one loop 55 times and grows from 20 to 732 blocks. The new blocks are appended against flow order, so `computeDominatorTree` needs more sweeps every round, up to 332 for the last tree. Those are the large intersections in the profile. Across all 30,000 corpus3 graphs at 1,000 words, 1,410 route a loop again in that pass, and every one of them fails. **Fix:** `canonicalizeNaturalLoops` throws when it would route the loop it routed in the previous rewrite. Once a loop is routed, only `hasSharedExitSelection` can pick it again, and routing it again just adds another junction layer of the same shape, so the pass can't end any other way. It's 7 lines, commit [b0e6631f](https://github.com/AlxcBTW/AnyPS5/commit/b0e6631fc625476f62a8f50b2328a41957611b54), directly on a396b019 and ready to cherry-pick. Timings use orishamir's `prof.cpp` on the first 500 corpus3 graphs at 1,000 words. This was Windows, MinGW GCC 15.2 -O2, median of 3, so it's slower than his Linux numbers. Columns are 0b56b7ad / a396b019 / fix: - all 500: 6.9 s / 28.4 s / 7.2 s - the 30 that fail on all three: 1.46 / 22.5 / 1.52 s - graphs 79, 449, 343, 383, 262, 14, 112 and 264: 1.25 / 21.6 / 1.30 s; graph 79 alone: 138 / 5,915 / 162 ms - the 470 that a396b019 structurizes: 5.4 / 6.0 / 5.6 s. The fix doesn't touch their path. The result is identical on every graph, meaning the same structurized graph or the same error. I checked all 30,000 corpus3 graphs at 0, 16, 100 and 1,000 words and at 16 with one 1,000-word block, plus 60,000 random reducible graphs. `agc_structurizer`, `agc_shader_control_flow` and `agc_spirv_module` pass, and so does the non-GPU suite (459/459). #2471 no longer merges into `main`. Since #2941 landed, its `iterationSelectionMerge` conflicts with `joinWithinIteration` from my `d692b963` in `findSelectionMerge`, so I couldn't run CI on the stack. That conflict is in my commit. I'm checking whether #2941 already covers `d692b963`'s shape, and I'll post a rebased stack on current `main` with the same corpus comparison. The fix itself only touches `canonicalizeNaturalLoops`, which #2941 doesn't change. AI-assisted: yes (Claude Code)
Scramblrrrr commented 2026-10-11 01:25:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T01:25:05Z.


Thanks @AlxcBTW — that is the same repeated-routing hot spot I saw. Your early refusal is a useful minimal fix because it preserves existing outputs; I am reviewing b0e6631f before choosing the PR path.

I already pushed the broader experiment on the tracking issue: the narrower synthetic-forwarder skip is 260a68b0 (only empty goto assignment -> current loop merge, not ordinary original empty blocks). It accepted two invalid SPIR-V outputs in a new synthetic shader sample, so it is not in #2471. With candidate checks on every pass and a direct conditional-exit check, c88762c4 passes both 30,000-program corpora vs a396b019: +1740 / +1597 graph fixes, zero regressions/new invariants/changed counts for formerly OK outputs. Two 400-attempt shader samples emit 780 modules, all externally Vulkan 1.3 valid. Internal verify warnings remain. This is a broader behavioral experiment, not an output-identical alternative to your early-refusal change.

Rebase work is public for coordination: 77c157d4 on codex/shared-loop-exit-current-main preserves #2941 and joinWithinIteration, with the one shared-tail regression now expecting no routing because main handles it directly. Focused control-flow tests pass, but the 400-attempt external sample has invalid outputs. I am comparing them against current main rather than labeling them as regressions. Do not use it as a ready head. The guarded rebase experiment is 1773c64b on codex/shared-loop-exit-current-main-guarded; its corpus and sample checks are running. If #2941 supersedes your d692b963 shape, I agree it is better to drop redundant machinery rather than carry both indefinitely. #2471 remains at a396b019 until the rebase is verified.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104172692 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104172692). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T01:25:05Z. --- Thanks @AlxcBTW — that is the same repeated-routing hot spot I saw. Your early refusal is a useful minimal fix because it preserves existing outputs; I am reviewing b0e6631f before choosing the PR path. I already pushed the broader experiment on the tracking issue: the narrower synthetic-forwarder skip is 260a68b0 (only empty goto assignment -> current loop merge, not ordinary original empty blocks). It accepted two invalid SPIR-V outputs in a new synthetic shader sample, so it is **not** in #2471. With candidate checks on every pass and a direct conditional-exit check, c88762c4 passes both 30,000-program corpora vs a396b019: +1740 / +1597 graph fixes, zero regressions/new invariants/changed counts for formerly OK outputs. Two 400-attempt shader samples emit 780 modules, all externally Vulkan 1.3 valid. Internal verify warnings remain. This is a broader behavioral experiment, not an output-identical alternative to your early-refusal change. Rebase work is public for coordination: 77c157d4 on `codex/shared-loop-exit-current-main` preserves #2941 and joinWithinIteration, with the one shared-tail regression now expecting no routing because main handles it directly. Focused control-flow tests pass, but the 400-attempt external sample has invalid outputs. I am comparing them against current main rather than labeling them as regressions. Do not use it as a ready head. The guarded rebase experiment is 1773c64b on `codex/shared-loop-exit-current-main-guarded`; its corpus and sample checks are running. If #2941 supersedes your d692b963 shape, I agree it is better to drop redundant machinery rather than carry both indefinitely. #2471 remains at a396b019 until the rebase is verified. AI-assisted (Codex).
Scramblrrrr commented 2026-10-11 01:30:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T01:30:52Z.


Correction to one metric in my Windows fuzz updates: the fourth field in this harness's results is the input block count, not the structurized output count. The parser's zero changed_successful_block_counts therefore does not establish unchanged output graphs. Please disregard that metric in my 260a68b0/c88762c4 reports (and the earlier Windows comparisons using that parser). The status-based fix/regression/invariant counts and the separate external SPIR-V validations are unaffected. The independent Linux checks reported by others use their own harness and are not affected by this correction.

I am reporting status and validator results separately from output identity. The guarded old-base experiment c88762c4 remains +1740/+1597 across 30,000 cases each, zero status regressions/new invariants, with 780 emitted sample modules externally valid. The guarded current-main candidate 1773c64b also emits 780 externally valid modules across its 800 attempts, with internal verifier warnings retained. Its full graph comparison against main is still running, so it is not in #2471 yet.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104213606 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104213606). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T01:30:52Z. --- Correction to one metric in my Windows fuzz updates: the fourth field in this harness's results is the **input** block count, not the structurized output count. The parser's zero `changed_successful_block_counts` therefore does not establish unchanged output graphs. Please disregard that metric in my 260a68b0/c88762c4 reports (and the earlier Windows comparisons using that parser). The status-based fix/regression/invariant counts and the separate external SPIR-V validations are unaffected. The independent Linux checks reported by others use their own harness and are not affected by this correction. I am reporting status and validator results separately from output identity. The guarded old-base experiment c88762c4 remains +1740/+1597 across 30,000 cases each, zero status regressions/new invariants, with 780 emitted sample modules externally valid. The guarded current-main candidate 1773c64b also emits 780 externally valid modules across its 800 attempts, with internal verifier warnings retained. Its full graph comparison against main is still running, so it is not in #2471 yet. AI-assisted (Codex).
Scramblrrrr commented 2026-10-11 01:49:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T01:49:49Z.


@AlxcBTW Windows cross-test of your b0e6631f directly on a396b019 is complete: all 30,000 cases at 16 words/block and all 30,000 at 1000 have the same status and error text as a396b019. This harness does not record output identity, so I am not claiming graph identity from those results. The a396b019 focused control-flow tests pass against b0e6631f. A single serial 500-case/1000-word run took 2.37 s here (not a median or a controlled cross-machine benchmark).

The guarded current-main behavioral experiment 1773c64b also completed its comparisons against 77bd928a: +6883 / +6633 fixes, zero status regressions/new invariant failures in the 30,000/30,000 cases, and all 780 emitted modules from the 800 synthetic shader attempts externally Vulkan-1.3 valid. It remains separate from this PR while we settle the #2941/base overlap. Your minimal early-refusal change is still the preferable small performance follow-up if retaining the current accepted-output behavior.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104346061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104346061). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T01:49:49Z. --- @AlxcBTW Windows cross-test of your **b0e6631f** directly on **a396b019** is complete: all 30,000 cases at 16 words/block and all 30,000 at 1000 have the same status and error text as a396b019. This harness does not record output identity, so I am not claiming graph identity from those results. The a396b019 focused control-flow tests pass against b0e6631f. A single serial 500-case/1000-word run took 2.37 s here (not a median or a controlled cross-machine benchmark). The guarded current-main behavioral experiment **1773c64b** also completed its comparisons against **77bd928a**: +6883 / +6633 fixes, zero status regressions/new invariant failures in the 30,000/30,000 cases, and all 780 emitted modules from the 800 synthetic shader attempts externally Vulkan-1.3 valid. It remains separate from this PR while we settle the #2941/base overlap. Your minimal early-refusal change is still the preferable small performance follow-up if retaining the current accepted-output behavior. AI-assisted (Codex).
Scramblrrrr commented 2026-10-11 02:10:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T02:10:48Z.


@AlxcBTW I tested removing just the overlapping global-join fallback from the guarded main rebase (the three-line trueJoins && isInsideLoopConstruct(...globalMerge) -> joinWithinIteration block). The iterationSelectionMerge path from #2941 stays, as does the separate shared-exit continue-join use of joinWithinIteration. Public experiment 3dc6b73a, parent 1773c64b: https://github.com/Scramblrrrr/AnyPS5/tree/codex/shared-loop-exit-main-overlap-reduced .

Both 30,000-case Windows comparisons at 16 and 1000 words/block have identical statuses and error text to 1773c64b; output identity is not recorded. Focused control-flow tests pass. Across 800 synthetic shader attempts, 780 emitted modules all externally Vulkan-1.3 validate, with no execution-equivalence warnings. Internal construct-verifier warnings remain: 92 in the original 400-attempt sample, 90 in the new sample (the latter was 86 on 1773c64b). So this is a simplification candidate, not a claim that every output is identical or that all internal checks are clean. Conventions pass. This does not remove your entire d692b963 helper, because our shared-exit continue path still uses it.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104496835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104496835). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T02:10:48Z. --- @AlxcBTW I tested removing just the overlapping global-join fallback from the guarded main rebase (the three-line `trueJoins && isInsideLoopConstruct(...globalMerge)` -> `joinWithinIteration` block). The iterationSelectionMerge path from #2941 stays, as does the separate shared-exit continue-join use of joinWithinIteration. Public experiment **3dc6b73a**, parent **1773c64b**: https://github.com/Scramblrrrr/AnyPS5/tree/codex/shared-loop-exit-main-overlap-reduced . Both 30,000-case Windows comparisons at 16 and 1000 words/block have identical statuses and error text to 1773c64b; output identity is not recorded. Focused control-flow tests pass. Across 800 synthetic shader attempts, 780 emitted modules all externally Vulkan-1.3 validate, with no execution-equivalence warnings. Internal construct-verifier warnings remain: 92 in the original 400-attempt sample, 90 in the new sample (the latter was 86 on 1773c64b). So this is a simplification candidate, not a claim that every output is identical or that all internal checks are clean. Conventions pass. This does not remove your entire d692b963 helper, because our shared-exit continue path still uses it. AI-assisted (Codex).
Scramblrrrr commented 2026-10-11 02:55:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T02:55:45Z.


@AlxcBTW I have moved the tested overlap-reduced version onto current main 961b25fe2 and updated this draft to bb5756097 so review is no longer blocked by the stale #2941 conflict. The control-flow sources/header and both test files are byte-for-byte unchanged from 3dc6b73a; the matching focused executable was rerun and conventions pass. GitHub now reports MERGEABLE. The description has been rewritten around the current implementation and explicitly retains the internal-warning counts and lack of output-identity data.

This stays a draft: I am not treating the remaining internal construct warnings as resolved or claiming a fresh 007 replay on this head. Your b0e6631f minimal early-refusal alternative remains separate and credited in the description. The previous a396b019 head is still available in the history/comments for comparison. The live 007 experiment uses 5fd30d503 in a separate runtime worktree; this PR update did not change its loaded driver.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104801400 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6104801400). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T02:55:45Z. --- @AlxcBTW I have moved the tested overlap-reduced version onto current main **961b25fe2** and updated this draft to **bb5756097** so review is no longer blocked by the stale #2941 conflict. The control-flow sources/header and both test files are byte-for-byte unchanged from **3dc6b73a**; the matching focused executable was rerun and conventions pass. GitHub now reports MERGEABLE. The description has been rewritten around the current implementation and explicitly retains the internal-warning counts and lack of output-identity data. This stays a draft: I am not treating the remaining internal construct warnings as resolved or claiming a fresh 007 replay on this head. Your b0e6631f minimal early-refusal alternative remains separate and credited in the description. The previous a396b019 head is still available in the history/comments for comparison. The live 007 experiment uses 5fd30d503 in a separate runtime worktree; this PR update did not change its loaded driver. AI-assisted (Codex).
AlxcBTW commented 2026-10-11 03:38:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T03:38:39Z.


@Scramblrrrr here are the results for your heads.

Our harness hashes the whole structurized graph: blocks, terminators, dom/post-dom sets, loops and components. It also checks every output:

  • exact post-dominators,
  • structured branches,
  • merges dominated by their header,
  • the construct rules hasStructuredConstructs checks,
  • that each original block still reaches its original targets through forwarders and route variables.

The corpora are orishamir's 30,000 seed-3 graphs at 0, 16 and 1,000 words and at 16 with one 1,000-word block, plus 60,000 random reducible graphs.

bb5756097 (= 3dc6b73a) vs 1773c64b. Status is the same on every graph, and neither has an invalid output.

  • Outputs are identical at 0 and 16 words (30,000/30,000).
  • They differ for 21 graphs at 1,000 words, 1 at 16 words with one 1,000-word block, and 2/3/5 random graphs.
  • All are valid on both sides. Of the 21, 13 get smaller without the fallback and 7 get larger. Mostly they move from the first pass to the shared-exit pass. Example: {{1}, {2, 3}, {4, 5}, {6}, {7, 3}, {1, 8}, {5}, {3, 1}, {}} at 1,000 words has 18 blocks with the fallback and 27 without.
  • Smallest difference: {{1}, {2, 3}, {4, 5}, {5}, {6, 3}, {1, 7}, {3, 1}, {}} at 16 words, 13 vs 12 blocks. With the fallback there's an extra empty forwarder before the copy of 3.

Is the dropped block covered by #2941? On plain main at 0 and 16 words, yes: same outputs on all 30,000 graphs. With big blocks, no: main + the block structurizes 5 more corpus graphs at 100 words and 20 more at 1,000, all valid; the 9-block graph above is one of them. In your stack the later passes pick all of them up. So dropping it costs no structurizations, only the 21 different outputs.

b0e6631f vs 45481ea4. 45481ea4 already stops the repeated routing. After routeLoopExits, every non-merge exit is a forwarder into the merge, so hasSharedExitSelection can't pick the loop again. On bb5756097, the b0e6631f check fired 0 times in 210,000 runs, and outputs are identical with and without it, so there's no need to carry it. 45481ea4 also lets that pass continue: it structurizes 811 more graphs at 1,000 words than 77c157d4 + b0e6631f, all valid.

Timing on orishamir's 500 graphs at 1,000 words (Windows, median of 3):

  • a396b019: 27.9 s
  • 77c157d4: 15.2 s
  • bb5756097: 8.5 s (8.1 s with b0e6631f, which is noise)
  • main: 4.8 s

Graph 79 now structurizes in 43 ms. Most of bb5756097's time is graph 449 (3.9 s), which now structurizes; main refuses it after 2.5 s.

Invalid outputs. bb5756097 never takes a graph from valid to invalid or failed, compared with either a396b019 + b0e6631f or main. 77c157d4's 1,937-2,182 invalid outputs come from main's first two passes, and your conditional-exit validation in 1773c64b removes every one.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105093406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6105093406). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-11T03:38:39Z. --- @Scramblrrrr here are the results for your heads. Our harness hashes the whole structurized graph: blocks, terminators, dom/post-dom sets, loops and components. It also checks every output: - exact post-dominators, - structured branches, - merges dominated by their header, - the construct rules `hasStructuredConstructs` checks, - that each original block still reaches its original targets through forwarders and route variables. The corpora are orishamir's 30,000 seed-3 graphs at 0, 16 and 1,000 words and at 16 with one 1,000-word block, plus 60,000 random reducible graphs. **bb5756097 (= 3dc6b73a) vs 1773c64b.** Status is the same on every graph, and neither has an invalid output. - Outputs are identical at 0 and 16 words (30,000/30,000). - They differ for 21 graphs at 1,000 words, 1 at 16 words with one 1,000-word block, and 2/3/5 random graphs. - All are valid on both sides. Of the 21, 13 get smaller without the fallback and 7 get larger. Mostly they move from the first pass to the shared-exit pass. Example: `{{1}, {2, 3}, {4, 5}, {6}, {7, 3}, {1, 8}, {5}, {3, 1}, {}}` at 1,000 words has 18 blocks with the fallback and 27 without. - Smallest difference: `{{1}, {2, 3}, {4, 5}, {5}, {6, 3}, {1, 7}, {3, 1}, {}}` at 16 words, 13 vs 12 blocks. With the fallback there's an extra empty forwarder before the copy of 3. **Is the dropped block covered by #2941?** On plain `main` at 0 and 16 words, yes: same outputs on all 30,000 graphs. With big blocks, no: `main` + the block structurizes 5 more corpus graphs at 100 words and 20 more at 1,000, all valid; the 9-block graph above is one of them. In your stack the later passes pick all of them up. So dropping it costs no structurizations, only the 21 different outputs. **b0e6631f vs 45481ea4.** 45481ea4 already stops the repeated routing. After `routeLoopExits`, every non-merge exit is a forwarder into the merge, so `hasSharedExitSelection` can't pick the loop again. On bb5756097, the b0e6631f check fired 0 times in 210,000 runs, and outputs are identical with and without it, so there's no need to carry it. 45481ea4 also lets that pass continue: it structurizes 811 more graphs at 1,000 words than 77c157d4 + b0e6631f, all valid. Timing on orishamir's 500 graphs at 1,000 words (Windows, median of 3): - a396b019: 27.9 s - 77c157d4: 15.2 s - bb5756097: 8.5 s (8.1 s with b0e6631f, which is noise) - `main`: 4.8 s Graph 79 now structurizes in 43 ms. Most of bb5756097's time is graph 449 (3.9 s), which now structurizes; `main` refuses it after 2.5 s. **Invalid outputs.** bb5756097 never takes a graph from valid to invalid or failed, compared with either a396b019 + b0e6631f or `main`. 77c157d4's 1,937-2,182 invalid outputs come from `main`'s first two passes, and your conditional-exit validation in 1773c64b removes every one. AI-assisted: yes (Claude Code)
Mouhand-Kaddo commented 2026-10-11 07:54:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:54:52Z.


Additional platform validation of standalone PR head bb57560979875c78277a72d2868315f61c548aea (2026-10-11):

Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release, BUILD_TESTING=ON.

3 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.

Checks: agc_structurizer, agc_spirv_module, agc_shader_control_flow.

Command after building: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_(shader_control_flow|structurizer|spirv_module)$".

This scope checks CPU-side behavior; no GPU execution result is claimed.

No title/gameplay validation. These results cover the standalone head, not a merge with current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106878829 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6106878829). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-11T07:54:52Z. --- <!-- anyps5-platform-validation:bb57560979875c78277a72d2868315f61c548aea --> Additional platform validation of standalone PR head `bb57560979875c78277a72d2868315f61c548aea` (2026-10-11): **Linux: passed** — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release, `BUILD_TESTING=ON`. 3 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run. Checks: `agc_structurizer`, `agc_spirv_module`, `agc_shader_control_flow`. Command after building: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_(shader_control_flow|structurizer|spirv_module)$"`. This scope checks CPU-side behavior; no GPU execution result is claimed. No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Scramblrrrr commented 2026-10-11 12:54:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T12:54:01Z.


@AlxcBTW Thank you for the full-graph hashes and independent structured/reachability checks. This fills the output-identity gap in my status/error-only comparisons. I will link your exact corpora and results in the description rather than presenting them as my own run.

Your distinction about the removed fallback is helpful: it is redundant on plain main for the small-block corpus, but not on main alone for large blocks; the later passes in our stack recover those cases, with some different valid outputs. I will correct that explanation. I also agree b0e6631f should remain out of this stack: your zero firings and identical outputs on the guarded head are stronger evidence than my older-head status check. The median-of-three timing and graph-449 observation are useful and will stay attributed to your Windows runs.

Main has since changed GraphBuilder/RequestSerializer, so I will validate that update separately before advancing this draft. My separate synthetic end-to-end internal warnings remain disclosed; I am not equating your corpus result with resolving that other sample. Thanks also to Mouhand-Kaddo for the focused Linux CPU checks.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109231672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6109231672). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T12:54:01Z. --- @AlxcBTW Thank you for the full-graph hashes and independent structured/reachability checks. This fills the output-identity gap in my status/error-only comparisons. I will link your exact corpora and results in the description rather than presenting them as my own run. Your distinction about the removed fallback is helpful: it is redundant on plain main for the small-block corpus, but not on main alone for large blocks; the later passes in our stack recover those cases, with some different valid outputs. I will correct that explanation. I also agree b0e6631f should remain out of this stack: your zero firings and identical outputs on the guarded head are stronger evidence than my older-head status check. The median-of-three timing and graph-449 observation are useful and will stay attributed to your Windows runs. Main has since changed GraphBuilder/RequestSerializer, so I will validate that update separately before advancing this draft. My separate synthetic end-to-end internal warnings remain disclosed; I am not equating your corpus result with resolving that other sample. Thanks also to Mouhand-Kaddo for the focused Linux CPU checks. AI-assisted (Codex).
Scramblrrrr commented 2026-10-11 13:23:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T13:23:25Z.


Rebased onto main a11c8f7f70, new head 3943287d63. Topic implementation/header/tests unchanged from bb5756097, but GraphBuilder/request serialization changed on main, so the focused executables were freshly compiled/linked with the current-main shader library and the topic Structurizer override. ControlFlow and Structurizer pass; 30,000 16-word cases plus 500 1000-word cases have identical statuses/error text to the prior topic head. No full standalone suite or output-hash claim for these local runs.

The remaining local end-to-end warnings were a harness error: it used ordinary dominance for construct membership instead of structural dominance (including declared merge/continue edges). In synthetic case 8530, a loop-body selection incorrectly included blocks after its enclosing loop merge. Independently recomputing structural dominance in the local harness fixes that attribution without changing the production implementation or suppressing errors. Across both synthetic corpora, both padding sizes and wave32/wave64: 800 attempts, 780 emitted, 780 externally Vulkan 1.3-valid, zero construct/structured-branch/execution-equivalence warnings. Negative control with old main 77bd928a: 100 attempts, 25 emitted, 23 warned outputs and 15 externally invalid modules, so the corrected checker still detects failures. Historical warning counts remain described with this correction in the PR body.

Thanks again @AlxcBTW for the independent full-graph/structured-dominance validation; it helped isolate this discrepancy. Description and conventions updated; marked ready for maintainer review. No title code/captures uploaded. AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109481618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6109481618). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T13:23:25Z. --- Rebased onto **main a11c8f7f70a0ed4e71504a89de69e8cdae687817**, new head **3943287d63f7fea8e45de0d76a62334f9f09069a**. Topic implementation/header/tests unchanged from bb5756097, but GraphBuilder/request serialization changed on main, so the focused executables were freshly compiled/linked with the current-main shader library and the topic Structurizer override. ControlFlow and Structurizer pass; 30,000 16-word cases plus 500 1000-word cases have identical statuses/error text to the prior topic head. No full standalone suite or output-hash claim for these local runs. The remaining local end-to-end warnings were a harness error: it used ordinary dominance for construct membership instead of structural dominance (including declared merge/continue edges). In synthetic case 8530, a loop-body selection incorrectly included blocks after its enclosing loop merge. Independently recomputing structural dominance in the local harness fixes that attribution without changing the production implementation or suppressing errors. Across both synthetic corpora, both padding sizes and wave32/wave64: **800 attempts, 780 emitted, 780 externally Vulkan 1.3-valid, zero construct/structured-branch/execution-equivalence warnings**. Negative control with old main 77bd928a: 100 attempts, 25 emitted, 23 warned outputs and 15 externally invalid modules, so the corrected checker still detects failures. Historical warning counts remain described with this correction in the PR body. Thanks again @AlxcBTW for the independent full-graph/structured-dominance validation; it helped isolate this discrepancy. Description and conventions updated; marked ready for maintainer review. No title code/captures uploaded. AI-assisted (Codex).
adriadam10 commented 2026-10-11 21:23:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:23:52Z.


Checked on current main: build and scoped ctest (libSceAgc, libSceAgcDriver) green, agc_structurizer, agc_structurizer_intersection_off and agc_shader_control_flow pass and all three fail with the Structurizer.cpp/.hpp change reverted. The extra passes only run after the two existing ones fail and every candidate is validated by hasStructuredConstructs, otherwise the original error is rethrown, so graphs main structurizes are unchanged. The large-block and shared-exit regressions reported by orishamir are covered by the new tests, and AlxcBTW's full-graph hash checks apply to the same code. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113926169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6113926169). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:23:52Z. --- Checked on current main: build and scoped ctest (libSceAgc, libSceAgcDriver) green, `agc_structurizer`, `agc_structurizer_intersection_off` and `agc_shader_control_flow` pass and all three fail with the `Structurizer.cpp`/`.hpp` change reverted. The extra passes only run after the two existing ones fail and every candidate is validated by `hasStructuredConstructs`, otherwise the original error is rethrown, so graphs `main` structurizes are unchanged. The large-block and shared-exit regressions reported by orishamir are covered by the new tests, and AlxcBTW's full-graph hash checks apply to the same code. Merging.
Mouhand-Kaddo commented 2026-10-11 21:28:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T21:28:58Z.


Windows Demon's Souls shader replay result: the legal PPSA01342 v1.04 startup capture below still fails after this merged into main 14a7e64dc:

SPIR-V validation after optimization failed:
The continue construct with the continue target '26[%26]' is not structurally post dominated by the back-edge block '45299[%45299]'

Initial validation passes; the first failing optimizer pass is block merging. A semantic self-loop ends up with its instruction block as the continuation, and merging folds that continuation into the empty loop header. A synthetic loop containing a buffer store reproduces the same failure on current main.

#4018 adds a dedicated empty continue target for that self-loop and preserves this PR's inner-loop latch handling. Both the synthetic regression and the captured game shader pass with it; the current focused ControlFlow, Structurizer and optimizer tests pass 3/3 on Windows. This is shader preparation evidence, not a Demon's Souls main-menu result. The private game capture remains local.

AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113976313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2471#issuecomment-6113976313). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-11T21:28:58Z. --- Windows Demon's Souls shader replay result: the legal PPSA01342 v1.04 startup capture below still fails after this merged into main `14a7e64dc`: ```text SPIR-V validation after optimization failed: The continue construct with the continue target '26[%26]' is not structurally post dominated by the back-edge block '45299[%45299]' ``` Initial validation passes; the first failing optimizer pass is block merging. A semantic self-loop ends up with its instruction block as the continuation, and merging folds that continuation into the empty loop header. A synthetic loop containing a buffer store reproduces the same failure on current main. #4018 adds a dedicated empty continue target for that self-loop and preserves this PR's inner-loop latch handling. Both the synthetic regression and the captured game shader pass with it; the current focused ControlFlow, Structurizer and optimizer tests pass 3/3 on Windows. This is shader preparation evidence, not a Demon's Souls main-menu result. The private game capture remains local. AI-assisted: yes (Codex).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2471
No description provided.