Skip to content

perf(recompiler): preserve sorted dominance sets during insertion - #2521

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:perf/shader-sorted-dominance-sets
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:perf/shader-sorted-dominance-sets

Conversation

@Celegans12

Copy link
Copy Markdown
Contributor

What

Both dominance analyses sort a whole set after inserting one block ID. The sets already start sorted and unique, and intersections preserve that order. Insert at lower_bound only when the ID is absent.

This changes the two insertion sites in computeDominatorTree and computePostDominators. Visitation order, convergence and graph rewriting stay unchanged. Six differential fixtures compare complete dominance vectors with the original algorithms across diamonds, loops, non-exiting SCCs, unreachable blocks and permuted IDs.

#2105 changes post-dominator visitation order; #2276 changes dominance queries and region traversal; #1493 extracts shared helpers. None implements these two insertion changes.

Synthetic whole-Structurize medians were 7.5108 to 3.4704 ms for 50 diamonds and 2.3872 to 2.0880 ms for 20 shared-merge branches: three samples after warm-up, alternating order, graph construction excluded. Initial/final GraphToString bytes matched. These two cases do not establish startup or FPS gains.

Tested

Windows 11, MinGW-w64 GCC 15.2.0: configure -DBUILD_TESTING=ON, full build, libs and registration passed. Tested tree e14758cbec exactly equals main 1f0c9fef56 plus this feature; #2473 is merged.

CTest: 556 executed passes, three skips, no failures. Two VideoOut modes skipped because main forces SDL's offscreen driver; both exact built modes passed separately with native Windows SDL. The remaining skip is the deliberate missing-Vulkan negative test. Raw upstream/local skip gates remain failed; native passes are supplemental evidence.

Focused agc_structurizer and agc_shader_control_flow tests passed.

Linux/lavapipe: full build, libs and registration passed on the same tree. CTest recorded 539 executed passes, 29 skips out of 568 cases, no failures; executed cases each passed three repetitions. Skips comprise 27 unchanged platform/device cases and two newly registered VideoOut modes consistent with main's offscreen/display skip path. Individual skip output was not captured. The helper predates the JUnit skip checker; exit 0 does not establish a current skip-policy pass.

Not tested: standalone title run or console behavior.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed shader core/shader agc libSceAgc* labels Oct 10, 2026
@Celegans12
Celegans12 force-pushed the perf/shader-sorted-dominance-sets branch from 86c2332 to 8be3db2 Compare October 10, 2026 04:13
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 10, 2026
Both dominance analyses start from sorted unique sets and intersect them.
Insert the current block ID with lower_bound instead of sorting again.
Preserve every intermediate set and the existing ID-order iteration.
Keep the generic unsorted helper and all graph rewrite logic unchanged.
Compare both analyses against the original algorithms on six raw CFGs.
Cover finite loops, closed SCCs, unreachable islands and permuted IDs.
@adriadam10
adriadam10 force-pushed the perf/shader-sorted-dominance-sets branch from 8be3db2 to f6fbb48 Compare October 10, 2026 07:31
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main: the only conflict was in tests/Structurizer.cpp, next to the post-dominator check and case added by #2105; kept both sides, no change to Structurizer.cpp. AGC/AgcDriver ctest passes on Linux (agc_structurizer included). The sets start sorted/unique and intersectSorted preserves order, so inserting at lower_bound matches addUnique + sortUnique. Merging on green CI.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@adriadam10
adriadam10 merged commit 4e9d298 into boykopovar:main Oct 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants