shader: reuse loop increment proofs for Ghost of Yotei #1878

Closed
github-bot wants to merge 4 commits from gh-pr/1878/head into gh-pr/1878/base
Owner

@⁠MrFr3di on GitHub · 2026-10-24 11:23 UTC · original
MrFr3di:perf/loop-proof-cache-upstream → main · +442 −20 · 8 files · 4 commits · closed without merging

Summary

Ghost of Yotei compute shaders repeatedly trigger the same expensive loop increment-guard proof for different resource uses. This adds substantial CPU shader-translation time.

Cache successful and unsuccessful proofs within each Tracker, keyed by (phi, compare, increment_block) and invalidated on IR mutations. Use-specific, induction-step and lane checks remain outside the cache.

Also replace the ordered lookup tables inside LoopBoundProof with hash tables.

Performance

Paired A/B measurements on captured compute shaders, Windows x64. CPU compilation time before Vulkan pipeline creation.

Corpus Paired runs Before After
131 compute inputs 7 56.953 s 3.188 s
125 ordinary inputs 21 1.1927 s 1.1986 s

The complete corpus shows a 17.43× median paired speedup. Ordinary inputs show a +0.77% median paired time change, with an observed interval of −1.03% to +1.66%.

Testing

  • Focused Windows build and resource_tracking_tests passed.
  • Tests cover cache reuse, positive and negative result invalidation, CFG and IR mutations, and instruction lifetime.
  • An independent Boolean checker covers 400 generated expressions, 64 assignments and both polarities.
  • Focused ASan/UBSan checks passed.

Additional testing with other games and AMD GPUs would be appreciated to help identify any compatibility or performance regressions.


Development and testing were carried out with assistance from Codex and Claude. I independently reviewed the changes.

**@⁠MrFr3di** on GitHub · 2026-10-24 11:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1878) `MrFr3di:perf/loop-proof-cache-upstream` → `main` · +442 −20 · 8 files · 4 commits · closed without merging ## Summary Ghost of Yotei compute shaders repeatedly trigger the same expensive loop increment-guard proof for different resource uses. This adds substantial CPU shader-translation time. Cache successful and unsuccessful proofs within each `Tracker`, keyed by `(phi, compare, increment_block)` and invalidated on IR mutations. Use-specific, induction-step and lane checks remain outside the cache. Also replace the ordered lookup tables inside `LoopBoundProof` with hash tables. ## Performance Paired A/B measurements on captured compute shaders, Windows x64. CPU compilation time before Vulkan pipeline creation. | Corpus | Paired runs | Before | After | |---|---:|---:|---:| | 131 compute inputs | 7 | 56.953 s | 3.188 s | | 125 ordinary inputs | 21 | 1.1927 s | 1.1986 s | The complete corpus shows a **17.43× median paired speedup**. Ordinary inputs show a **+0.77% median paired time change**, with an observed interval of −1.03% to +1.66%. ## Testing - Focused Windows build and `resource_tracking_tests` passed. - Tests cover cache reuse, positive and negative result invalidation, CFG and IR mutations, and instruction lifetime. - An independent Boolean checker covers 400 generated expressions, 64 assignments and both polarities. - Focused ASan/UBSan checks passed. Additional testing with other games and AMD GPUs would be appreciated to help identify any compatibility or performance regressions. --- Development and testing were carried out with assistance from Codex and Claude. I independently reviewed the changes.
Repeated resource uses in Ghost of Yotei compute shaders rebuild the same
increment-guard proof. Cache both outcomes per Tracker and IR mutation
epoch, and use hash tables for proof lookup state.

Keep use, step and lane checks outside the cache. Cover invalidation,
negative answers and a finite independent Boolean oracle in focused tests.
Preserve IR mutation notification in SetArg alongside the upstream ArgSlot optimization.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:07:47 +00:00
github-bot closed this pull request 2026-11-26 10:07:47 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · edited 2026-10-28 17:15 UTC

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 372cfb14a9 and 2e591c2c9f.

Files selected for processing: 5
  • CMakeLists.txt
  • src/graphics/shader/recompiler/ir/Value.cpp
  • src/graphics/shader/recompiler/ir/Value.h
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ResourceTrackingTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The changes add a thread-local IR mutation epoch and record selected instruction, branch, dead-code-elimination, and resource-tracking mutations. BoundedInduction now uses an epoch-checked cache for increment-guard proofs. The test target adds cache tests for invalidation, proof agreement, and Boolean truth-table results.

Suggested reviewers: nmzik

Priority: Normal

Change: Refactor

Merge Risk: Minimal · up to 2e591

No merge-blocking issue was established for the proof cache.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: reusing loop increment-guard proofs (a cache) in the shader recompiler, motivated by Ghost of Yotei. The raw summary confirms the Tracker-level proof cache with invali…
Description check Passed The description states the purpose (repeated expensive loop increment-guard proofs for Ghost of Yotei compute shaders), the cache design (keyed by (phi, compare, increment_block), invalidated on IR mu…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: reusing loop increment-guard proofs (a cache) in the shader recompiler, motivated by Ghost of Yotei. The raw summary confirms the Tracker-level proof cache with invalidation on IR mutations, and the description describes the same change. The title is specific and concise, so the check passes.

Full details: Description check

Explanation

The description states the purpose (repeated expensive loop increment-guard proofs for Ghost of Yotei compute shaders), the cache design (keyed by (phi, compare, increment_block), invalidated on IR mutations), the hash-table change in LoopBoundProof, performance measurements, and test coverage. These match the file-level summaries and PR objectives, so the description is related to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-24 11:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1878#issuecomment-6383700386) · edited 2026-10-28 17:15 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1878?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/6c0140186250a9ac7ed50786b2426271750a7a20/.coderabbit.yaml>) - **Commit**: [6c01401](<https://github.com/KytyPS5/KytyPS5/commit/6c0140186250a9ac7ed50786b2426271750a7a20>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `b1ea3501-d1f0-4fc3-a8ac-8fdf8df95178` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 372cfb14a9d407dd472f10abc14d5a6f7ddb1701 and 2e591c2c9ff600d5ae49d032883fcf127c46d8e0. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 5</strong></summary> <dl> <dd> * `CMakeLists.txt` * `src/graphics/shader/recompiler/ir/Value.cpp` * `src/graphics/shader/recompiler/ir/Value.h` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/ResourceTrackingTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> The changes add a thread-local IR mutation epoch and record selected instruction, branch, dead-code-elimination, and resource-tracking mutations. `BoundedInduction` now uses an epoch-checked cache for increment-guard proofs. The test target adds cache tests for invalidation, proof agreement, and Boolean truth-table results. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"2e591c2c9ff600d5ae49d032883fcf127c46d8e0" --> **Change:** Refactor <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>2e591</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `2e591` --> <!-- final_review_risk_coverage:{"sourceCommitId":"2e591c2c9ff600d5ae49d032883fcf127c46d8e0","coveredCommitId":"2e591c2c9ff600d5ae49d032883fcf127c46d8e0","kind":"reviewed"} --> No merge-blocking issue was established for the proof cache. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 5</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: reusing loop increment-guard proofs (a cache) in the shader recompiler, motivated by Ghost of Yotei. The raw summary confirms the Tracker-level proof cache with invali… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the purpose (repeated expensive loop increment-guard proofs for Ghost of Yotei compute shaders), the cache design (keyed by (phi, compare, increment_block), invalidated on IR mu… | | Docstring Coverage | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> **Explanation** The title names the main change: reusing loop increment-guard proofs (a cache) in the shader recompiler, motivated by Ghost of Yotei. The raw summary confirms the Tracker-level proof cache with invalidation on IR mutations, and the description describes the same change. The title is specific and concise, so the check passes. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> **Explanation** The description states the purpose (repeated expensive loop increment-guard proofs for Ghost of Yotei compute shaders), the cache design (keyed by (phi, compare, increment_block), invalidated on IR mutations), the hash-table change in LoopBoundProof, performance measurements, and test coverage. These match the file-level summaries and PR objectives, so the description is related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1878)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -1756,0 +1829,4 @@
}
const bool guarded = ComputeIncrementGuard(phi, compare, increment_block);
m_increment_guards.insert_or_assign(key, IncrementGuard {epoch, guarded});
return guarded;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · edited 2026-10-24 16:49 UTC

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

sed -n '1,115p' src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp
sed -n '1225,1305p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '3110,3155p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '3320,3365p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp

Repository: KytyPS5/KytyPS5

Length of output: 11051


Script executed:

set -o pipefail
printf '%s\n' '--- phase order and mutation epoch ---'
rg -n -F --glob '*.{cpp,h}' -e 'EliminateDeadCode(' -e 'NoteIrMutation(' -e 'g_ir_mutation_epoch' -e 'BoundedInduction(' -e 'IncrementGuarded(' src/graphics/shader/recompiler/ir
printf '%s\n' '--- current implementations ---'
sed -n '390,445p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '1725,1795p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '1815,1885p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '2435,2515p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '3070,3170p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '3290,3375p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
printf '%s\n' '--- diff for the relevant files ---'
git diff --unified=30 8291cfeb04237a5e36f5d377e620cd0e6acd5805 519273af93d40ab947eccbbd880b11ea521d0067 -- src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp
printf '%s\n' '--- focused tests mentioning cache, DCE, or mutation ---'
rg -n -i -F --glob '*.{cpp,h}' -e 'increment.guard' -e 'IncrementGuard' -e 'EliminateDeadCode' -e 'mutation_epoch' -e 'NoteIrMutation' src/graphics/shader/recompiler | head -240

Repository: KytyPS5/KytyPS5

Length of output: 42466


Script executed:

set -o pipefail
printf '%s\n' '--- proof semantics and complete bounded-induction flow ---'
rg -n -F --glob '*.cpp' -e 'bool Excludes' -e 'Excludes(' -e 'LoopBoundProof' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '1360,1455p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '1770,1820p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
printf '%s\n' '--- focused test definitions and fixtures ---'
rg -n -F --glob '*.{cpp,h}' -e 'LoopProofTestAccess' -e 'IncrementGuarded' -e 'EliminateDeadCode' -e 'Block::condition' -e 'condition = Value' .
printf '%s\n' '--- DCE and epoch definitions ---'
sed -n '1,95p' src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp
sed -n '95,125p' src/graphics/shader/recompiler/ir/Value.h

Repository: KytyPS5/KytyPS5

Length of output: 15131


Script executed:

set -o pipefail
sed -n '145,190p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
sed -n '1,205p' tests/LoopProofCacheTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 11150


Script executed:

set -o pipefail
printf '%s\n' '--- DCE-related mutators ---'
sed -n '190,290p' src/graphics/shader/recompiler/ir/Value.cpp
sed -n '145,180p' src/graphics/shader/recompiler/ir/Value.h
printf '%s\n' '--- PlanScalarReads and intervening notifications ---'
sed -n '880,1020p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp

Repository: KytyPS5/KytyPS5

Length of output: 10654


Invalidate increment proofs before DCE.

EliminateDeadCode() can replace a proof-relevant Block::condition without advancing g_ir_mutation_epoch. The cache tests show that this change can alter the verdict for the same (phi, compare, increment_block) key. A proof cached by FoldBoundedLoopSelectors() can therefore be reused by PlanIndirectDescriptors() with a stale verdict.

Suggested fix
 		PlanScalarReads();
+		NoteIrMutation();
 		EliminateDeadCode(m_program.blocks);
 		PlanIndirectDescriptors();

✅ Addressed in commit 372cfb1

**@⁠coderabbitai[bot]** on GitHub · 2026-10-24 11:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1878#discussion_r4366993375) · edited 2026-10-24 16:49 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** <details> <summary>🔎 Supported by static analysis</summary> <dl> <dd> Script executed: ```bash sed -n '1,115p' src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp sed -n '1225,1305p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '3110,3155p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '3320,3365p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 11051 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- phase order and mutation epoch ---' rg -n -F --glob '*.{cpp,h}' -e 'EliminateDeadCode(' -e 'NoteIrMutation(' -e 'g_ir_mutation_epoch' -e 'BoundedInduction(' -e 'IncrementGuarded(' src/graphics/shader/recompiler/ir printf '%s\n' '--- current implementations ---' sed -n '390,445p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '1725,1795p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '1815,1885p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '2435,2515p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '3070,3170p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '3290,3375p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp printf '%s\n' '--- diff for the relevant files ---' git diff --unified=30 8291cfeb04237a5e36f5d377e620cd0e6acd5805 519273af93d40ab947eccbbd880b11ea521d0067 -- src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp printf '%s\n' '--- focused tests mentioning cache, DCE, or mutation ---' rg -n -i -F --glob '*.{cpp,h}' -e 'increment.guard' -e 'IncrementGuard' -e 'EliminateDeadCode' -e 'mutation_epoch' -e 'NoteIrMutation' src/graphics/shader/recompiler | head -240 ``` Repository: KytyPS5/KytyPS5 Length of output: 42466 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- proof semantics and complete bounded-induction flow ---' rg -n -F --glob '*.cpp' -e 'bool Excludes' -e 'Excludes(' -e 'LoopBoundProof' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '1360,1455p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '1770,1820p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp printf '%s\n' '--- focused test definitions and fixtures ---' rg -n -F --glob '*.{cpp,h}' -e 'LoopProofTestAccess' -e 'IncrementGuarded' -e 'EliminateDeadCode' -e 'Block::condition' -e 'condition = Value' . printf '%s\n' '--- DCE and epoch definitions ---' sed -n '1,95p' src/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cpp sed -n '95,125p' src/graphics/shader/recompiler/ir/Value.h ``` Repository: KytyPS5/KytyPS5 Length of output: 15131 --- Script executed: ```bash set -o pipefail sed -n '145,190p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp sed -n '1,205p' tests/LoopProofCacheTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 11150 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- DCE-related mutators ---' sed -n '190,290p' src/graphics/shader/recompiler/ir/Value.cpp sed -n '145,180p' src/graphics/shader/recompiler/ir/Value.h printf '%s\n' '--- PlanScalarReads and intervening notifications ---' sed -n '880,1020p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 10654 --- </dd> </dl> </details> **Invalidate increment proofs before DCE.** `EliminateDeadCode()` can replace a proof-relevant `Block::condition` without advancing `g_ir_mutation_epoch`. The cache tests show that this change can alter the verdict for the same `(phi, compare, increment_block)` key. A proof cached by `FoldBoundedLoopSelectors()` can therefore be reused by `PlanIndirectDescriptors()` with a stale verdict. <details> <summary>Suggested fix</summary> <dl> <dd> ```diff PlanScalarReads(); + NoteIrMutation(); EliminateDeadCode(m_program.blocks); PlanIndirectDescriptors(); ``` </dd> </dl> </details> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2619aba43a2febc03ab419a1 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 372cfb1
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8291cfeb04 and 519273af93.

Files selected for processing: 7
  • CMakeLists.txt
  • src/graphics/shader/recompiler/ir/Block.cpp
  • src/graphics/shader/recompiler/ir/Value.cpp
  • src/graphics/shader/recompiler/ir/Value.h
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/LoopProofCacheTests.cpp
  • tests/ResourceTrackingTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-24 11:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1878#pullrequestreview-5638095491) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/8291cfeb04237a5e36f5d377e620cd0e6acd5805/.coderabbit.yaml>) - **Commit**: [8291cfe](<https://github.com/KytyPS5/KytyPS5/commit/8291cfeb04237a5e36f5d377e620cd0e6acd5805>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `0babe70b-003e-4f4d-b60e-148577b39850` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 8291cfeb04237a5e36f5d377e620cd0e6acd5805 and 519273af93d40ab947eccbbd880b11ea521d0067. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 7</summary> <dl> <dd> * `CMakeLists.txt` * `src/graphics/shader/recompiler/ir/Block.cpp` * `src/graphics/shader/recompiler/ir/Value.cpp` * `src/graphics/shader/recompiler/ir/Value.h` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/LoopProofCacheTests.cpp` * `tests/ResourceTrackingTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=f007ae29-109f-43cf-b0d6-241aabcea3a7 attempt=4ad1b783-8c68-441c-aeeb-852400cd44e3 batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-11-03 18:03 UTC · original

Test report: Ghost of Yōtei (PPSA26344) on current main, Windows 11, RX 9070 XT (AMD driver 26.10.1).

On main (dfec14aa8) the game needs #1967 to get past its first compute shaders (without it, Tracker::CollectScalarRead overflows the stack), and #1758 and #2062 for the descriptor pool and the warm boot. With those three, a cold boot stays on the splash screen for me: compute shader 0xb920ac9e14cb5fb8 (102 blocks, 3 loops) does not get through resource tracking, and the compiler thread spends its time creating and destroying LoopBoundProof objects. Offline this shader takes about as long on 893b03552 + #1967 (11322 ms), so the slow proof is not new.

With this PR merged on top (it merges cleanly):

  • I recompiled offline the 172 shaders one cold boot requested (113 compute, 43 pixel, 16 vertex; their code and compile inputs dumped from that run; one process per shader, PrepareShaderSource + TranslateProgram):
all 172 shaders slowest
main + #1967 24119 ms 0xb920ac9e14cb5fb8 12431 ms, 0x69ba1a07c7a95510 8722 ms, 0x3d82c2913cac198d 1796 ms
main + #1967 + #1878 1682 ms 0x386c6a44da561c0d 275 ms
  • The resource plans (ExtractResourcePlan, serialized with SaveResourcePlan and hashed) are the same for all 172 shaders with and without this PR (and the same in two runs of the same build).
  • In the game, the cold boot gets past the splash and keeps loading: 58 vertex, 89 pixel and 207 compute shaders compiled, no fatal error. The screen stays black while it loads, as it did on the 893b03552 build. Without this PR, three cold boots stayed on the boot screen ("Waiting for frames", 0 draw calls) after 35 to 56 compute shaders. Two cold boots with --graphics-debug-dump got further without this PR (about 124 compute shaders), so the stall also depends on timing.

So on current main this PR also fixes a stall, not only compile time.

**@⁠Nawid3333** on GitHub · 2026-11-03 18:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1878#issuecomment-6611648192) Test report: Ghost of Yōtei (PPSA26344) on current main, Windows 11, RX 9070 XT (AMD driver 26.10.1). On main (dfec14aa8) the game needs #1967 to get past its first compute shaders (without it, `Tracker::CollectScalarRead` overflows the stack), and #1758 and #2062 for the descriptor pool and the warm boot. With those three, a cold boot stays on the splash screen for me: compute shader `0xb920ac9e14cb5fb8` (102 blocks, 3 loops) does not get through resource tracking, and the compiler thread spends its time creating and destroying `LoopBoundProof` objects. Offline this shader takes about as long on 893b03552 + #1967 (11322 ms), so the slow proof is not new. With this PR merged on top (it merges cleanly): - I recompiled offline the 172 shaders one cold boot requested (113 compute, 43 pixel, 16 vertex; their code and compile inputs dumped from that run; one process per shader, `PrepareShaderSource` + `TranslateProgram`): | | all 172 shaders | slowest | |---|---|---| | main + #1967 | 24119 ms | `0xb920ac9e14cb5fb8` 12431 ms, `0x69ba1a07c7a95510` 8722 ms, `0x3d82c2913cac198d` 1796 ms | | main + #1967 + #1878 | 1682 ms | `0x386c6a44da561c0d` 275 ms | - The resource plans (`ExtractResourcePlan`, serialized with `SaveResourcePlan` and hashed) are the same for all 172 shaders with and without this PR (and the same in two runs of the same build). - In the game, the cold boot gets past the splash and keeps loading: 58 vertex, 89 pixel and 207 compute shaders compiled, no fatal error. The screen stays black while it loads, as it did on the 893b03552 build. Without this PR, three cold boots stayed on the boot screen ("Waiting for frames", 0 draw calls) after 35 to 56 compute shaders. Two cold boots with `--graphics-debug-dump` got further without this PR (about 124 compute shaders), so the stall also depends on timing. So on current main this PR also fixes a stall, not only compile time.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.