diff options
Diffstat (limited to 'src')
| -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); |