summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-03-17 05:33:25 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:23 +0200
commit32b6c63485626f10b3bc8efb0239064cc781115e (patch)
tree1b89a275933058b7d132c8eec1469cd2f5825776 /src/shader_recompiler/ir_opt
parentshader: Fix instruction transitions in and out of Phi (diff)
downloadyuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.gz
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.bz2
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.lz
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.xz
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.tar.zst
yuzu-32b6c63485626f10b3bc8efb0239064cc781115e.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp10
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:
}
if (same.IsEmpty()) {
// The phi is unreachable or in the start block
- const auto first_not_phi{std::ranges::find_if_not(block->Instructions(), IsPhi)};
+ // First remove the phi node from the block, it will be reinserted
+ IR::Block::InstructionList& list{block->Instructions()};
+ list.erase(IR::Block::InstructionList::s_iterator_to(phi));
+
+ // Insert an undef instruction after all phi nodes (to keep phi instructions on top)
+ const auto first_not_phi{std::ranges::find_if_not(list, IsPhi)};
same = IR::Value{&*block->PrependNewInst(first_not_phi, undef_opcode)};
+
+ // Insert the phi node after the undef opcode, this will be replaced with an identity
+ list.insert(first_not_phi, phi);
}
// Reroute all uses of phi to same and remove phi
phi.ReplaceUsesWith(same);