diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-03-14 07:41:05 +0100 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:23 +0200 |
commit | 71f96fa6366dc6dd306a953bca1b958fb32bc55a (patch) | |
tree | 12e13f9502e4b9510446c967a831e5d4bacb729e /src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp | |
parent | spirv: Add SignedZeroInfNanPreserve logic (diff) | |
download | yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar.gz yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar.bz2 yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar.lz yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar.xz yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.tar.zst yuzu-71f96fa6366dc6dd306a953bca1b958fb32bc55a.zip |
Diffstat (limited to 'src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp')
-rw-r--r-- | src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp | 10 |
1 files changed, 6 insertions, 4 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 132b2012a..8ad59f42e 100644 --- a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp +++ b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp @@ -10,12 +10,14 @@ namespace Shader::Optimization { -void DeadCodeEliminationPass(IR::Block& block) { +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::Inst& inst : block | std::views::reverse) { - if (!inst.HasUses() && !inst.MayHaveSideEffects()) { - inst.Invalidate(); + 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(); + } } } } |