diff options
| author | 2021-03-17 01:33:25 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 32b6c63485626f10b3bc8efb0239064cc781115e (patch) | |
| tree | 1b89a275933058b7d132c8eec1469cd2f5825776 /src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |
| parent | shader: Fix instruction transitions in and out of Phi (diff) | |
| download | yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.gz yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.xz yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.zip | |
shader: Reorder phi nodes when redefined as undefined opcodes
Diffstat (limited to 'src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index f89fd51c8..d09bcec36 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -181,8 +181,16 @@ private: | |||
| 181 | } | 181 | } |
| 182 | if (same.IsEmpty()) { | 182 | if (same.IsEmpty()) { |
| 183 | // The phi is unreachable or in the start block | 183 | // The phi is unreachable or in the start block |
| 184 | const auto first_not_phi{std::ranges::find_if_not(block->Instructions(), IsPhi)}; | 184 | // First remove the phi node from the block, it will be reinserted |
| 185 | IR::Block::InstructionList& list{block->Instructions()}; | ||
| 186 | list.erase(IR::Block::InstructionList::s_iterator_to(phi)); | ||
| 187 | |||
| 188 | // Insert an undef instruction after all phi nodes (to keep phi instructions on top) | ||
| 189 | const auto first_not_phi{std::ranges::find_if_not(list, IsPhi)}; | ||
| 185 | same = IR::Value{&*block->PrependNewInst(first_not_phi, undef_opcode)}; | 190 | same = IR::Value{&*block->PrependNewInst(first_not_phi, undef_opcode)}; |
| 191 | |||
| 192 | // Insert the phi node after the undef opcode, this will be replaced with an identity | ||
| 193 | list.insert(first_not_phi, phi); | ||
| 186 | } | 194 | } |
| 187 | // Reroute all uses of phi to same and remove phi | 195 | // Reroute all uses of phi to same and remove phi |
| 188 | phi.ReplaceUsesWith(same); | 196 | phi.ReplaceUsesWith(same); |