From 8af9297f0972d0aaa8306369c5d04926b886a89e Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Sun, 14 Feb 2021 01:24:32 -0300
Subject: shader: Misc fixes

---
 src/shader_recompiler/frontend/ir/microinstruction.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'src/shader_recompiler/frontend/ir/microinstruction.cpp')

diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index b4ae371bd1..9279b96928 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -143,19 +143,21 @@ Value Inst::Arg(size_t index) const {
 }
 
 void Inst::SetArg(size_t index, Value value) {
-    if (op == Opcode::Phi) {
-        throw LogicError("Setting argument on a phi instruction");
-    }
-    if (index >= NumArgsOf(op)) {
+    if (index >= NumArgs()) {
         throw InvalidArgument("Out of bounds argument index {} in opcode {}", index, op);
     }
-    if (!args[index].IsImmediate()) {
-        UndoUse(args[index]);
+    const IR::Value arg{Arg(index)};
+    if (!arg.IsImmediate()) {
+        UndoUse(arg);
     }
     if (!value.IsImmediate()) {
         Use(value);
     }
-    args[index] = value;
+    if (op == Opcode::Phi) {
+        phi_args[index].second = value;
+    } else {
+        args[index] = value;
+    }
 }
 
 Block* Inst::PhiBlock(size_t index) const {
-- 
cgit v1.2.3-70-g09d2