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

Merged
Celegans12 merged 1 commit from upstream-pr/2521 into main 2026-10-10 07:36:31 +00:00
Celegans12 commented 2026-10-10 00:47:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-10T00:47:20Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4807431473 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2521). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-10T00:47:20Z. --- ### 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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-10 07:32:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:32:00Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095147218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2521#issuecomment-6095147218). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:32:00Z. --- 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.
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!2521
No description provided.