aco: move update_renames() out of get_reg()
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 16 Nov 2020 14:51:33 +0000 (14:51 +0000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 4 Dec 2020 20:27:31 +0000 (20:27 +0000)
This is necessary for the next commit, which will pass a temporary copy of
the register file to get_reg().

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7656>

src/amd/compiler/aco_register_allocation.cpp

index 9f727576a6ab4af45db284df84abbb428a8c1997..42c7064ccb9a9165297a135db1a1c8796caea0fe 100644 (file)
@@ -1240,10 +1240,8 @@ PhysReg get_reg(ra_ctx& ctx,
    /* try to find space with live-range splits */
    res = get_reg_impl(ctx, reg_file, parallelcopies, info, instr);
 
-   if (res.second) {
-      update_renames(ctx, reg_file, parallelcopies, instr, instr->opcode != aco_opcode::p_create_vector);
+   if (res.second)
       return res.first;
-   }
 
    /* try using more registers */
 
@@ -1527,6 +1525,7 @@ void get_reg_for_operand(ra_ctx& ctx, RegisterFile& register_file,
 
          /* find free reg */
          PhysReg reg = get_reg(ctx, register_file, pc_op.getTemp(), parallelcopy, ctx.pseudo_dummy);
+         update_renames(ctx, register_file, parallelcopy, ctx.pseudo_dummy, true);
          Definition pc_def = Definition(PhysReg{reg}, pc_op.regClass());
          parallelcopy.emplace_back(pc_op, pc_def);
          blocking_var = true;
@@ -1535,6 +1534,7 @@ void get_reg_for_operand(ra_ctx& ctx, RegisterFile& register_file,
 
    } else {
       dst = get_reg(ctx, register_file, operand.getTemp(), parallelcopy, instr, operand_index);
+      update_renames(ctx, register_file, parallelcopy, instr, instr->opcode != aco_opcode::p_create_vector);
    }
 
    Operand pc_op = operand;
@@ -1899,8 +1899,10 @@ void register_allocation(Program *program, std::vector<IDSet>& live_out_per_bloc
                   break;
                }
             }
-            if (!definition.isFixed())
+            if (!definition.isFixed()) {
                definition.setFixed(get_reg(ctx, register_file, definition.getTemp(), parallelcopy, phi));
+               update_renames(ctx, register_file, parallelcopy, phi, true);
+            }
 
             /* process parallelcopy */
             for (std::pair<Operand, Definition> pc : parallelcopy) {
@@ -2195,6 +2197,7 @@ void register_allocation(Program *program, std::vector<IDSet>& live_out_per_bloc
                } else {
                   definition->setFixed(get_reg(ctx, register_file, tmp, parallelcopy, instr));
                }
+               update_renames(ctx, register_file, parallelcopy, instr, instr->opcode != aco_opcode::p_create_vector);
             }
 
             assert(definition->isFixed() && ((definition->getTemp().type() == RegType::vgpr && definition->physReg() >= 256) ||
@@ -2317,6 +2320,7 @@ void register_allocation(Program *program, std::vector<IDSet>& live_out_per_bloc
                Temp tmp = program->allocateTmp(can_sgpr ? s1 : v1);
                ctx.assignments.emplace_back();
                PhysReg reg = get_reg(ctx, register_file, tmp, parallelcopy, instr);
+               update_renames(ctx, register_file, parallelcopy, instr, true);
 
                aco_ptr<Instruction> mov;
                if (can_sgpr)