perf(shader): end dead code elimination when no released value is left dead #7494

Merged
milescoviello merged 1 commit from upstream-pr/7494 into main 2026-11-08 08:16:06 +00:00
milescoviello commented 2026-10-18 09:34:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T09:34:40Z.


What

DeadCodeEliminator::Eliminate repeats a pass over every block until a pass removes nothing. So every call that removes anything pays one more full pass that only confirms the result.

The pass walks the blocks and their instructions backwards. An instruction it has already visited can only become dead later in the pass when the removal of one of its users drops its last use. For a non-phi user, that argument is usually defined earlier and is still ahead in the walk. The exception is an argument the walk has already passed, such as a phi's input from a later block. Uses only shrink during the pass, and an instruction's side effects don't change.

The pass now keeps the arguments of the instructions it removes. It runs again only when one of them is still in a block, has no uses and has no side effects. If none is, nothing removable is left in the blocks, and the next pass would have removed nothing. When one is, the next pass runs as before. The set of removed instructions, the order of the instructions that remain, and so the SPIR-V are unchanged.

agc_ir_reclaim now checks that an unused phi in the first block and its input in a later block are both removed. That passes on main (in a second pass) and with this PR. With the recheck replaced by changed = false, it fails with "the input of an eliminated phi from a later block was not eliminated".

Tested

Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02.

  • ctest -R "^agc_|^shader_ir" on cb1d6e5bd6: 709/709 pass (3 skipped: host import sparse, sparse dma-buf import, stencil ref export). After rebasing onto 9caecfd2d5: agc_ir_reclaim, agc_masked_select and agc_constant_phi pass.
  • agc_shader_replay --spv (Release, ANYPS5_ENABLE_SPIRV_TOOLS off, ANYPS5_NO_SHADER_CACHE=1) on 420 shader requests I had dumped with APS5_DUMP_SHADERS: 355 from MXGP 26 (PPSA30839, two dumps), 61 from PPSA31162 and 4 from another app. On main cb1d6e5bd6 and with this PR, all 419 .spv files that are produced have the same SHA-256, and the replay output is identical, including the one request that fails on both.

Pass time, from a temporary timer and pass counter in Eliminate that are not part of this PR:

Replay Build DCE calls DCE passes DCE time
PPSA31162's largest compute shader (1,056,287 SPIR-V words), 20 runs per build, interleaved main 13 22 126.6 ± 6.2 ms (median 127.0)
this PR 13 13 85.4 ± 2.3 ms (median 85.1)
the 355 PPSA30839 requests in one replay, 3 runs per build, interleaved main 4,210 6,873 1,595.1, 1,620.4, 1,604.3 ms
this PR 4,210 4,544 1,249.6, 1,250.8, 1,279.6 ms

In the PPSA30839 requests, 334 passes beyond the first per call remain with this PR, for values that the walk had already passed. The largest shader's whole replay takes about 1.2 s of CPU time, so its gain is about 3.5% of that.

Title level: no speed claim. This is background shader preparation. I didn't run a title for it.

This is independent of #7431 (PlanBuilder::PatchReads) and #7491 (MaskedSelectEliminator), which change other passes of the same shader preparation. #7491 calls Eliminate after rounds that remove a select.

tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py reports no overlap with open pull requests.

Title capture

As the perf label asks, these are captures of one title and scene on one machine. MXGP26 (PPSA30839) ran from boot with APS5_TRACE_SECONDS=0:60, ANYPS5_NO_SHADER_CACHE=1 and a fresh run directory (cold AnyPS5 and NVIDIA caches), so the shaders compile inside the window. NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04, release libs, Xvfb display, no input. main dbac9fa15b was captured five times: before the PR captures, after them, and three more times in a row after that. Each PR capture and the first two main captures followed a rebuild of the release libraries; the last three main captures did not, and they came out lower. The change is main with this PR merged on top as a local merge commit (da0ca697c5e9). The time is the wall time of the Shader.PrepareArtifact slices on the shader prepare threads in each trace.

capture presents frame p50 / p90 artifacts prepared prepare time, total per artifact, mean / median
main 1 194 16.7 / 32.8 ms 935 87.3 s 93.4 / 27.7 ms
main 2 195 16.7 / 34.0 ms 956 91.4 s 95.6 / 29.6 ms
main 3 166 16.7 / 28.4 ms 961 82.1 s 85.4 / 27.3 ms
main 4 161 16.7 / 27.9 ms 946 77.6 s 82.1 / 24.7 ms
main 5 183 16.7 / 22.7 ms 939 78.4 s 83.5 / 22.8 ms
this PR 187 16.7 / 31.6 ms 946 95.2 s 100.6 / 28.5 ms

The five main captures span 17.7% in total prepare time, and the 13 prepare threads run in parallel with the title, so a title capture can't resolve a recompiler change of a few percent. The replay measurement above is this change's measurement. This PR's capture is above all five main captures in total prepare time. With one capture of the change I can't tell that apart from noise, and the replay measurement above points the other way. I can repeat the capture if that would help.

main 1 trace, digest, main 2 trace, digest, main 3 trace, digest, main 4 trace, digest, main 5 trace, digest, this PR trace, digest

{"commit":"dbac9fa15b61","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":120148.301},"presents":194,"frame_ms":{"p50":16.686,"p90":32.765,"p99":2921.590,"max":112847.624},"gpu_busy_ms_per_present":6.483,"worker_busy_pct":{"queue worker 0x0":88.481,"queue worker 0x20":73.127},"top_phases_ms_per_frame":{"Driver.Packet":1000.862,"Driver.Packet.dispatch":503.561,"Driver.Dispatch":503.451,"Shader.PrepareArtifact":450.125,"Driver.Packet.memory_wait":424.003,"Vulkan.GraphicsPipeline":132.519,"Vulkan.GraphicsPipelineLibrary":126.497,"Vulkan.GraphicsPipelinePrebuild":77.312},"trace_dropped":false,"trace":"aps5-trace-dbac9fa15b61-3.json.gz"}
{"commit":"da0ca697c5e9","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":117333.848},"presents":187,"frame_ms":{"p50":16.709,"p90":31.588,"p99":2098.845,"max":110882.020},"gpu_busy_ms_per_present":4.954,"worker_busy_pct":{"queue worker 0x0":88.094,"queue worker 0x20":71.639},"top_phases_ms_per_frame":{"Driver.Packet":1002.245,"Driver.Packet.dispatch":509.476,"Driver.Dispatch":509.370,"Shader.PrepareArtifact":509.078,"Driver.Packet.memory_wait":419.504,"Vulkan.GraphicsPipeline":125.361,"Vulkan.GraphicsPipelineLibrary":119.275,"Vulkan.GraphicsPipelinePrebuild":72.435},"trace_dropped":false,"trace":"aps5-trace-da0ca697c5e9-3.json.gz"}
  • Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04: VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -V on main e2a2914aa1 and on main + this PR (0aab6c1f35, a local merge). main: 815 of 815 pass. With this PR, 814 of 815 pass: agc_storage_written_buffer_order aborted in the dynamic loader before the test began (Inconsistency detected by ld.so: ... elf_machine_rela_relative: Assertion ... failed). A test in another PR's run hit the same assertion that evening, so it isn't this change. Rerun 5 times under the layer on the same merge, agc_storage_written_buffer_order passes 5 of 5 with no VUIDs. Neither log reports the layer missing. VUIDs on main and with this PR: VUID-vkCmdCopyBuffer-srcBuffer-00118 ×2, VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285 ×2, VUID-vkCmdWaitEvents-srcStageMask-01158 ×2, VUID-VkImageViewCreateInfo-usage-02275 ×6, VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 ×18, VUID-vkSetEvent-event-09543 ×2. None is new with this PR.
  • Windows 11 Pro 26220, RTX 4070 (NVIDIA 596.21), WinLibs GCC 15.2 r7, Release, by @screamm (comment): merged with #7516 on main 1d4164552 (and with #7520/#7522 in a second arm): agc_ir_reclaim (including the later-block phi case), agc_masked_select, agc_constant_phi and the 41-test shader set pass 3 of 3; identical shader-cache entries and replay hashes against two main runs (Showcase PPSA99005, RetroArch PPSA99169, vkQuake PPSA99010), static frames bit-identical, and draw-path recompile time within main's spread.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04 (Linux 6.8); NVIDIA RTX 4070 (596.21), Windows 11 (@screamm)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4908003377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T09:34:40Z. --- ### What `DeadCodeEliminator::Eliminate` repeats a pass over every block until a pass removes nothing. So every call that removes anything pays one more full pass that only confirms the result. The pass walks the blocks and their instructions backwards. An instruction it has already visited can only become dead later in the pass when the removal of one of its users drops its last use. For a non-phi user, that argument is usually defined earlier and is still ahead in the walk. The exception is an argument the walk has already passed, such as a phi's input from a later block. Uses only shrink during the pass, and an instruction's side effects don't change. The pass now keeps the arguments of the instructions it removes. It runs again only when one of them is still in a block, has no uses and has no side effects. If none is, nothing removable is left in the blocks, and the next pass would have removed nothing. When one is, the next pass runs as before. The set of removed instructions, the order of the instructions that remain, and so the SPIR-V are unchanged. `agc_ir_reclaim` now checks that an unused phi in the first block and its input in a later block are both removed. That passes on `main` (in a second pass) and with this PR. With the recheck replaced by `changed = false`, it fails with "the input of an eliminated phi from a later block was not eliminated". ### Tested Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02. - `ctest -R "^agc_|^shader_ir"` on cb1d6e5bd6: 709/709 pass (3 skipped: host import sparse, sparse dma-buf import, stencil ref export). After rebasing onto 9caecfd2d5: `agc_ir_reclaim`, `agc_masked_select` and `agc_constant_phi` pass. - `agc_shader_replay --spv` (Release, `ANYPS5_ENABLE_SPIRV_TOOLS` off, `ANYPS5_NO_SHADER_CACHE=1`) on 420 shader requests I had dumped with `APS5_DUMP_SHADERS`: 355 from MXGP 26 (PPSA30839, two dumps), 61 from PPSA31162 and 4 from another app. On `main` cb1d6e5bd6 and with this PR, all 419 `.spv` files that are produced have the same SHA-256, and the replay output is identical, including the one request that fails on both. **Pass time**, from a temporary timer and pass counter in `Eliminate` that are not part of this PR: | Replay | Build | DCE calls | DCE passes | DCE time | |---|---|---|---|---| | PPSA31162's largest compute shader (1,056,287 SPIR-V words), 20 runs per build, interleaved | `main` | 13 | 22 | 126.6 ± 6.2 ms (median 127.0) | | | this PR | 13 | 13 | 85.4 ± 2.3 ms (median 85.1) | | the 355 PPSA30839 requests in one replay, 3 runs per build, interleaved | `main` | 4,210 | 6,873 | 1,595.1, 1,620.4, 1,604.3 ms | | | this PR | 4,210 | 4,544 | 1,249.6, 1,250.8, 1,279.6 ms | In the PPSA30839 requests, 334 passes beyond the first per call remain with this PR, for values that the walk had already passed. The largest shader's whole replay takes about 1.2 s of CPU time, so its gain is about 3.5% of that. **Title level: no speed claim.** This is background shader preparation. I didn't run a title for it. This is independent of #7431 (`PlanBuilder::PatchReads`) and #7491 (`MaskedSelectEliminator`), which change other passes of the same shader preparation. #7491 calls `Eliminate` after rounds that remove a select. `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` reports no overlap with open pull requests. ### Title capture As the `perf` label asks, these are captures of one title and scene on one machine. MXGP26 (PPSA30839) ran from boot with `APS5_TRACE_SECONDS=0:60`, `ANYPS5_NO_SHADER_CACHE=1` and a fresh run directory (cold AnyPS5 and NVIDIA caches), so the shaders compile inside the window. NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04, release libs, Xvfb display, no input. `main` dbac9fa15b61 was captured five times: before the PR captures, after them, and three more times in a row after that. Each PR capture and the first two `main` captures followed a rebuild of the release libraries; the last three `main` captures did not, and they came out lower. The change is `main` with this PR merged on top as a local merge commit (da0ca697c5e9). The time is the wall time of the `Shader.PrepareArtifact` slices on the `shader prepare` threads in each trace. | capture | presents | frame p50 / p90 | artifacts prepared | prepare time, total | per artifact, mean / median | |---|---:|---:|---:|---:|---:| | `main` 1 | 194 | 16.7 / 32.8 ms | 935 | 87.3 s | 93.4 / 27.7 ms | | `main` 2 | 195 | 16.7 / 34.0 ms | 956 | 91.4 s | 95.6 / 29.6 ms | | `main` 3 | 166 | 16.7 / 28.4 ms | 961 | 82.1 s | 85.4 / 27.3 ms | | `main` 4 | 161 | 16.7 / 27.9 ms | 946 | 77.6 s | 82.1 / 24.7 ms | | `main` 5 | 183 | 16.7 / 22.7 ms | 939 | 78.4 s | 83.5 / 22.8 ms | | this PR | 187 | 16.7 / 31.6 ms | 946 | 95.2 s | 100.6 / 28.5 ms | The five `main` captures span 17.7% in total prepare time, and the 13 prepare threads run in parallel with the title, so a title capture can't resolve a recompiler change of a few percent. The replay measurement above is this change's measurement. This PR's capture is above all five `main` captures in total prepare time. With one capture of the change I can't tell that apart from noise, and the replay measurement above points the other way. I can repeat the capture if that would help. [`main` 1 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main-digest.txt), [`main` 2 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main2-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main2-digest.txt), [`main` 3 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main3-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main3-digest.txt), [`main` 4 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main4-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main4-digest.txt), [`main` 5 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main5-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main5-digest.txt), [this PR trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-7494-aps5-trace-da0ca697c5e9-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-7494-digest.txt) ```json {"commit":"dbac9fa15b61","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":120148.301},"presents":194,"frame_ms":{"p50":16.686,"p90":32.765,"p99":2921.590,"max":112847.624},"gpu_busy_ms_per_present":6.483,"worker_busy_pct":{"queue worker 0x0":88.481,"queue worker 0x20":73.127},"top_phases_ms_per_frame":{"Driver.Packet":1000.862,"Driver.Packet.dispatch":503.561,"Driver.Dispatch":503.451,"Shader.PrepareArtifact":450.125,"Driver.Packet.memory_wait":424.003,"Vulkan.GraphicsPipeline":132.519,"Vulkan.GraphicsPipelineLibrary":126.497,"Vulkan.GraphicsPipelinePrebuild":77.312},"trace_dropped":false,"trace":"aps5-trace-dbac9fa15b61-3.json.gz"} {"commit":"da0ca697c5e9","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":117333.848},"presents":187,"frame_ms":{"p50":16.709,"p90":31.588,"p99":2098.845,"max":110882.020},"gpu_busy_ms_per_present":4.954,"worker_busy_pct":{"queue worker 0x0":88.094,"queue worker 0x20":71.639},"top_phases_ms_per_frame":{"Driver.Packet":1002.245,"Driver.Packet.dispatch":509.476,"Driver.Dispatch":509.370,"Shader.PrepareArtifact":509.078,"Driver.Packet.memory_wait":419.504,"Vulkan.GraphicsPipeline":125.361,"Vulkan.GraphicsPipelineLibrary":119.275,"Vulkan.GraphicsPipelinePrebuild":72.435},"trace_dropped":false,"trace":"aps5-trace-da0ca697c5e9-3.json.gz"} ``` - Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04: `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -V` on `main` e2a2914aa1 and on `main` + this PR (0aab6c1f35, a local merge). `main`: 815 of 815 pass. With this PR, 814 of 815 pass: `agc_storage_written_buffer_order` aborted in the dynamic loader before the test began (`Inconsistency detected by ld.so: ... elf_machine_rela_relative: Assertion ... failed`). A test in another PR's run hit the same assertion that evening, so it isn't this change. Rerun 5 times under the layer on the same merge, `agc_storage_written_buffer_order` passes 5 of 5 with no VUIDs. Neither log reports the layer missing. VUIDs on `main` and with this PR: `VUID-vkCmdCopyBuffer-srcBuffer-00118` ×2, `VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285` ×2, `VUID-vkCmdWaitEvents-srcStageMask-01158` ×2, `VUID-VkImageViewCreateInfo-usage-02275` ×6, `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` ×18, `VUID-vkSetEvent-event-09543` ×2. None is new with this PR. - Windows 11 Pro 26220, RTX 4070 (NVIDIA 596.21), WinLibs GCC 15.2 r7, Release, by @screamm ([comment](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6293959316)): merged with #7516 on `main` 1d4164552 (and with #7520/#7522 in a second arm): `agc_ir_reclaim` (including the later-block phi case), `agc_masked_select`, `agc_constant_phi` and the 41-test shader set pass 3 of 3; identical shader-cache entries and replay hashes against two `main` runs (Showcase PPSA99005, RetroArch PPSA99169, vkQuake PPSA99010), static frames bit-identical, and draw-path recompile time within `main`'s spread. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04 (Linux 6.8); NVIDIA RTX 4070 (596.21), Windows 11 (@screamm) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
milescoviello commented 2026-10-19 21:35:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T21:35:32Z.


The title capture the perf label asks for is now in the description, with both summary lines, the traces and the digests: MXGP26 from boot, a cold shader cache, main dbac9fa15b against main + this PR (da0ca697c5e9). The five main captures span 17.7% in total shader prepare time, so the capture can't resolve this change, and the replay measurement in the description is still its measurement. This PR's capture is above all five main captures in total prepare time. With one capture of the change I can't tell that apart from noise, and the replay measurement above points the other way. I can repeat the capture if that would help.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6277884879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6277884879). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T21:35:32Z. --- The title capture the `perf` label asks for is now in the description, with both summary lines, the traces and the digests: MXGP26 from boot, a cold shader cache, `main` dbac9fa15b61 against `main` + this PR (da0ca697c5e9). The five `main` captures span 17.7% in total shader prepare time, so the capture can't resolve this change, and the replay measurement in the description is still its measurement. This PR's capture is above all five `main` captures in total prepare time. With one capture of the change I can't tell that apart from noise, and the replay measurement above points the other way. I can repeat the capture if that would help. AI-assisted: yes (Claude Code)
screamm commented 2026-10-20 15:01:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-20T15:01:47Z.


Independent run, Windows. Host: Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2 r7, Release. This PR at 0aab6c1f3 was merged with #7516 (f099292f8; they share no file) on main 1d4164552 (arm A). A second arm added #7520 (d484281b6) and #7522 (cabf6ad53). All merges were clean. Targeted build: the shader and AGC test targets plus libs.

  • agc_ir_reclaim, including the new later-block phi case: 3 of 3 on both arms. Also 3x on both arms: agc_masked_select, agc_constant_phi, the ^shader_|^agc_shader_ set and the f16/f32 min/max GPU tests (41 tests). Arm A passed 40 of 41 and arm B 41 of 41, none skipped. The arm A exception, shader_cache_runtime_sources, hit its 180 s limit once on a loaded host and passed 3 of 3 serially.
  • Shader output, three homebrews, fresh shader cache directory per run, 60 s: Showcase PPSA99005 52 entries, RetroArch PPSA99169 24, vkQuake PPSA99010 52. Entry count, keys and payloads are the same for two main runs, arm A and arm B. I matched keys with the source-version word masked and compared payloads with host pointers masked: 5 Showcase entries hold a host address and differ between two main runs too. Showcase's two dumped compute requests replay (agc_shader_replay --spv) to identical SHA-256 on all three builds. That matches your replay result: the SPIR-V doesn't change.
  • Cold-cache A B A B, main, A, main, A, then one B run, 90 s each. Settings: ANYPS5_NO_SHADER_CACHE=1, a freshly relinked run directory each time, APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1 APS5_TRACE_SUMMARY_EVERY=10. No run had a stop line. These titles have no Shader.PrepareArtifact slices, because they compile on the draw path. So I summed the draw-path "recompile" row of the [draw] driver phases lines over each run:
    • vkQuake: main 2594.5 / 2223.2 ms (16.7% apart), arm A 2530.6 / 2473.1 ms (+3.9% on the mean), arm B 2245.5 ms.
    • Showcase: main 46.8 / 35.0 ms, arm A 42.2 ms, arm B 39.7 ms. The other arm A run ran during a load spike on the host and is not usable.
    • RetroArch: 8924 to 9147 presents per run, p50 8.34 ms in every run.
    • All arm values are within the main spread, as you expected: a title capture can't resolve this change. These are the first title runs of it on Windows.
  • Frame dumps: vkQuake's four static console and loading screens are bit-identical between main and both arms. The animated frames of all three titles differ between two main runs too, so they can't be compared.
  • A negative control doesn't apply to a bit-exact optimisation. I didn't repeat your changed = false check; identical output stands in for it.
  • tools/check_conventions.py --base origin/main and git diff --check: pass.

Not checked: a full build, the agc_driver_ GPU suite, a pass count or DCE timing (that needs your temporary counter), AMD/Intel, Linux.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6293959316 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6293959316). Originally posted by [screamm](https://github.com/screamm) on 2026-10-20T15:01:47Z. --- Independent run, Windows. Host: Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2 r7, Release. This PR at `0aab6c1f3` was merged with #7516 (`f099292f8`; they share no file) on `main` `1d4164552` (arm A). A second arm added #7520 (`d484281b6`) and #7522 (`cabf6ad53`). All merges were clean. Targeted build: the shader and AGC test targets plus `libs`. - `agc_ir_reclaim`, including the new later-block phi case: 3 of 3 on both arms. Also 3x on both arms: `agc_masked_select`, `agc_constant_phi`, the `^shader_|^agc_shader_` set and the f16/f32 min/max GPU tests (41 tests). Arm A passed 40 of 41 and arm B 41 of 41, none skipped. The arm A exception, `shader_cache_runtime_sources`, hit its 180 s limit once on a loaded host and passed 3 of 3 serially. - Shader output, three homebrews, fresh shader cache directory per run, 60 s: Showcase PPSA99005 52 entries, RetroArch PPSA99169 24, vkQuake PPSA99010 52. Entry count, keys and payloads are the same for two `main` runs, arm A and arm B. I matched keys with the source-version word masked and compared payloads with host pointers masked: 5 Showcase entries hold a host address and differ between two `main` runs too. Showcase's two dumped compute requests replay (`agc_shader_replay --spv`) to identical SHA-256 on all three builds. That matches your replay result: the SPIR-V doesn't change. - Cold-cache A B A B, `main`, A, `main`, A, then one B run, 90 s each. Settings: `ANYPS5_NO_SHADER_CACHE=1`, a freshly relinked run directory each time, `APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1 APS5_TRACE_SUMMARY_EVERY=10`. No run had a stop line. These titles have no `Shader.PrepareArtifact` slices, because they compile on the draw path. So I summed the draw-path "recompile" row of the `[draw] driver phases` lines over each run: - vkQuake: `main` 2594.5 / 2223.2 ms (16.7% apart), arm A 2530.6 / 2473.1 ms (+3.9% on the mean), arm B 2245.5 ms. - Showcase: `main` 46.8 / 35.0 ms, arm A 42.2 ms, arm B 39.7 ms. The other arm A run ran during a load spike on the host and is not usable. - RetroArch: 8924 to 9147 presents per run, p50 8.34 ms in every run. - All arm values are within the `main` spread, as you expected: a title capture can't resolve this change. These are the first title runs of it on Windows. - Frame dumps: vkQuake's four static console and loading screens are bit-identical between `main` and both arms. The animated frames of all three titles differ between two `main` runs too, so they can't be compared. - A negative control doesn't apply to a bit-exact optimisation. I didn't repeat your `changed = false` check; identical output stands in for it. - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. Not checked: a full build, the `agc_driver_` GPU suite, a pass count or DCE timing (that needs your temporary counter), AMD/Intel, Linux. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
milescoviello commented 2026-10-20 15:03:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:03:39Z.


Thanks @screamm, the first Windows title runs of this one, and the identical cache entries and replay hashes are the right check for a bit-exact change. Added to the description.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6293998868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6293998868). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T15:03:39Z. --- Thanks @screamm, the first Windows title runs of this one, and the identical cache entries and replay hashes are the right check for a bit-exact change. Added to the description. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-21 03:25:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T03:25:42Z.


A second title for this one: Crimson Desert (PPSA25286), whose start-up is CPU-bound on preparing registered shaders. I dumped 6,065 of its registration requests as they were prepared, then replayed them with agc_shader_replay --prepare. Release, SPIRV-Tools off, ANYPS5_NO_SHADER_CACHE=1, i7-13700K, task-clock over a fixed subset of 152 requests, 8 interleaved runs per build:

build median range
main 5d10ea9ea0 16.58 s 16.50 to 16.75 s
main + this PR (0aab6c1f35, merged cleanly) 16.16 s 15.97 to 16.60 s

That's 2.5 % less CPU for these requests. The prepared SPIR-V of the 152 requests is byte-identical to main's.

I also tried replacing the remaining rescans with a worklist over the removed instructions' operands. All 6,065 prepared modules and 458 recompiled MXGP and SMB3D modules came out identical, but it measured 16.11 s (16.04 to 16.20 s), no better than this PR. So I'm not proposing it: this PR already takes nearly all of the dead-code pass's cost here.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307260446 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6307260446). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T03:25:42Z. --- A second title for this one: Crimson Desert (PPSA25286), whose start-up is CPU-bound on preparing registered shaders. I dumped 6,065 of its registration requests as they were prepared, then replayed them with `agc_shader_replay --prepare`. Release, SPIRV-Tools off, `ANYPS5_NO_SHADER_CACHE=1`, i7-13700K, task-clock over a fixed subset of 152 requests, 8 interleaved runs per build: | build | median | range | |---|---|---| | `main` 5d10ea9ea0 | 16.58 s | 16.50 to 16.75 s | | `main` + this PR (0aab6c1f35, merged cleanly) | 16.16 s | 15.97 to 16.60 s | That's 2.5 % less CPU for these requests. The prepared SPIR-V of the 152 requests is byte-identical to `main`'s. I also tried replacing the remaining rescans with a worklist over the removed instructions' operands. All 6,065 prepared modules and 458 recompiled MXGP and SMB3D modules came out identical, but it measured 16.11 s (16.04 to 16.20 s), no better than this PR. So I'm not proposing it: this PR already takes nearly all of the dead-code pass's cost here. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-21 23:46:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:46:22Z.

Review: APPROVED


The termination check is sound for the reverse walk: removing an instruction can only make one of its operands newly dead, so the pass repeats only when a released operand still belongs to a block, has no uses and has no side effects. The new later-block phi regression exercises that exception, and the reported control fails when the recheck is removed. The replay reports byte-identical SPIR-V/output hashes across 419 produced modules, and the second title replay shows a small CPU-time reduction with overlapping ranges. The MXGP title capture is noisy and slower than all five main captures; the description appropriately makes no title-speed claim. Conventions, eligibility, labels and report pass; hosted product jobs are skipped. Current tools/pr_overlap.py reports no overlap across 1,105 open PRs. I did not run the tests locally. No blocking issue found; approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607592787 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#pullrequestreview-5607592787). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:46:22Z. **Review:** APPROVED --- The termination check is sound for the reverse walk: removing an instruction can only make one of its operands newly dead, so the pass repeats only when a released operand still belongs to a block, has no uses and has no side effects. The new later-block phi regression exercises that exception, and the reported control fails when the recheck is removed. The replay reports byte-identical SPIR-V/output hashes across 419 produced modules, and the second title replay shows a small CPU-time reduction with overlapping ranges. The MXGP title capture is noisy and slower than all five main captures; the description appropriately makes no title-speed claim. Conventions, eligibility, labels and report pass; hosted product jobs are skipped. Current `tools/pr_overlap.py` reports no overlap across 1,105 open PRs. I did not run the tests locally. No blocking issue found; approved.
milescoviello commented 2026-10-21 23:47:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T23:47:38Z.


Thanks @MarcZX10 for the review, and for re-running pr_overlap.py across the open PRs.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329118690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7494#issuecomment-6329118690). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T23:47:38Z. --- Thanks @MarcZX10 for the review, and for re-running `pr_overlap.py` across the open PRs. AI-assisted: yes (Claude Code)
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!7494
No description provided.