summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-22 18:29:59 -0300
committerGravatar ameerj2021-07-22 21:51:29 -0400
commit92a01984e6315f3c214990926c8fa5b4474ed339 (patch)
treee7f4daea4da9141a0f4d0b668777098671a16bf0 /src/shader_recompiler
parentshader: Add missing UndoUse case for GetSparseFromOp (diff)
downloadyuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.gz
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.xz
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.zip
shader: Remove invalidated blocks in dead code elimination pass
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp
index f9c5334b5..1e4a3fdae 100644
--- a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp
+++ b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp
@@ -14,9 +14,12 @@ void DeadCodeEliminationPass(IR::Program& program) {
14 // We iterate over the instructions in reverse order. 14 // We iterate over the instructions in reverse order.
15 // This is because removing an instruction reduces the number of uses for earlier instructions. 15 // This is because removing an instruction reduces the number of uses for earlier instructions.
16 for (IR::Block* const block : program.post_order_blocks) { 16 for (IR::Block* const block : program.post_order_blocks) {
17 for (IR::Inst& inst : block->Instructions() | std::views::reverse) { 17 auto it{block->end()};
18 if (!inst.HasUses() && !inst.MayHaveSideEffects()) { 18 while (it != block->begin()) {
19 inst.Invalidate(); 19 --it;
20 if (!it->HasUses() && !it->MayHaveSideEffects()) {
21 it->Invalidate();
22 it = block->Instructions().erase(it);
20 } 23 }
21 } 24 }
22 } 25 }