From efb80c171553ad4205d29bb6273627bdbe7208ed Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 8 Aug 2023 21:02:21 +0100 Subject: [PATCH] aco: summarize register demand after handling branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes various dEQP-VK.ray_query.builtin.rayqueryterminate.* crashes. fossil-db (gfx1100): Totals from 196 (0.15% of 133461) affected shaders: PreSGPRs: 8342 -> 8558 (+2.59%) Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Fixes: 5a536eca9ca7 ("aco: calculate correct register demand for branch instructions") Part-of: --- src/amd/compiler/aco_live_var_analysis.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 */