diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp index aa837b3c742..989e26b44b9 100644 --- a/src/amd/compiler/aco_live_var_analysis.cpp +++ b/src/amd/compiler/aco_live_var_analysis.cpp @@ -132,7 +132,6 @@ process_live_temps_per_block(Program* program, live& lives, Block* block, unsign RegisterDemand new_demand; register_demand.resize(block->instructions.size()); - RegisterDemand block_register_demand; IDSet live = lives.live_out[block->index]; /* initialize register demand */ @@ -209,15 +208,8 @@ process_live_temps_per_block(Program* program, live& lives, Block* block, unsign RegisterDemand before_instr = new_demand; handle_def_fixed_to_op(®ister_demand[idx], before_instr, insn, op_idx); } - - block_register_demand.update(register_demand[idx]); } - /* update block's register demand for a last time */ - block_register_demand.update(new_demand); - if (program->progress < CompilationProgress::after_ra) - block->register_demand = block_register_demand; - /* handle phi definitions */ uint16_t linear_phi_defs = 0; int phi_idx = idx; @@ -497,13 +489,21 @@ live_var_analysis(Program* program) unsigned block_idx = --worklist; process_live_temps_per_block(program, result, &program->blocks[block_idx], worklist, phi_info); - new_demand.update(program->blocks[block_idx].register_demand); } /* Handle branches: we will insert copies created for linear phis just before the branch. */ for (Block& block : program->blocks) { result.register_demand[block.index].back().sgpr += phi_info[block.index].linear_phi_defs; result.register_demand[block.index].back().sgpr -= phi_info[block.index].linear_phi_ops; + + /* update block's register demand */ + if (program->progress < CompilationProgress::after_ra) { + block.register_demand = RegisterDemand(); + for (RegisterDemand& demand : result.register_demand[block.index]) + block.register_demand.update(demand); + } + + new_demand.update(block.register_demand); } /* calculate the program's register demand and number of waves */