summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-22 23:29:59 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:29 +0200
commit92a01984e6315f3c214990926c8fa5b4474ed339 (patch)
treee7f4daea4da9141a0f4d0b668777098671a16bf0
parentshader: Add missing UndoUse case for GetSparseFromOp (diff)
downloadyuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.gz
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.bz2
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.lz
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.xz
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.tar.zst
yuzu-92a01984e6315f3c214990926c8fa5b4474ed339.zip
Diffstat (limited to '')
-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) {
// We iterate over the instructions in reverse order.
// This is because removing an instruction reduces the number of uses for earlier instructions.
for (IR::Block* const block : program.post_order_blocks) {
- for (IR::Inst& inst : block->Instructions() | std::views::reverse) {
- if (!inst.HasUses() && !inst.MayHaveSideEffects()) {
- inst.Invalidate();
+ auto it{block->end()};
+ while (it != block->begin()) {
+ --it;
+ if (!it->HasUses() && !it->MayHaveSideEffects()) {
+ it->Invalidate();
+ it = block->Instructions().erase(it);
}
}
}