From da8096e6e35af250dcc56a1af76b8a211df63a90 Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Sat, 6 Feb 2021 02:38:22 -0300
Subject: shader: Properly store phi on Inst

---
 src/shader_recompiler/frontend/ir/basic_block.cpp | 33 ++++++++++-------------
 1 file changed, 14 insertions(+), 19 deletions(-)

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

diff --git a/src/shader_recompiler/frontend/ir/basic_block.cpp b/src/shader_recompiler/frontend/ir/basic_block.cpp
index 1a5d821357..50c6a83cd0 100644
--- a/src/shader_recompiler/frontend/ir/basic_block.cpp
+++ b/src/shader_recompiler/frontend/ir/basic_block.cpp
@@ -129,26 +129,21 @@ std::string DumpBlock(const Block& block, const std::map<const Block*, size_t>&
         } else {
             ret += fmt::format("         {}", op); // '%00000 = ' -> 1 + 5 + 3 = 9 spaces
         }
-        if (op == Opcode::Phi) {
-            size_t val_index{0};
-            for (const auto& [phi_block, phi_val] : inst.PhiOperands()) {
-                ret += val_index != 0 ? ", " : " ";
-                ret += fmt::format("[ {}, {} ]", ArgToIndex(block_to_index, inst_to_index, phi_val),
-                                   BlockToIndex(block_to_index, phi_block));
-                ++val_index;
+        const size_t arg_count{NumArgsOf(op)};
+        for (size_t arg_index = 0; arg_index < arg_count; ++arg_index) {
+            const Value arg{inst.Arg(arg_index)};
+            const std::string arg_str{ArgToIndex(block_to_index, inst_to_index, arg)};
+            ret += arg_index != 0 ? ", " : " ";
+            if (op == Opcode::Phi) {
+                ret += fmt::format("[ {}, {} ]", arg_index,
+                                   BlockToIndex(block_to_index, inst.PhiBlock(arg_index)));
+            } else {
+                ret += arg_str;
             }
-        } else {
-            const size_t arg_count{NumArgsOf(op)};
-            for (size_t arg_index = 0; arg_index < arg_count; ++arg_index) {
-                const Value arg{inst.Arg(arg_index)};
-                ret += arg_index != 0 ? ", " : " ";
-                ret += ArgToIndex(block_to_index, inst_to_index, arg);
-
-                const Type actual_type{arg.Type()};
-                const Type expected_type{ArgTypeOf(op, arg_index)};
-                if (!AreTypesCompatible(actual_type, expected_type)) {
-                    ret += fmt::format("<type error: {} != {}>", actual_type, expected_type);
-                }
+            const Type actual_type{arg.Type()};
+            const Type expected_type{ArgTypeOf(op, arg_index)};
+            if (!AreTypesCompatible(actual_type, expected_type)) {
+                ret += fmt::format("<type error: {} != {}>", actual_type, expected_type);
             }
         }
         if (TypeOf(op) != Type::Void) {
-- 
cgit v1.2.3-70-g09d2