From 34b2f00d9cd206c3888c4e4df51a1709ce55afff 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: (cherry picked from commit efb80c171553ad4205d29bb6273627bdbe7208ed) --- .pick_status.json | 2 +- src/amd/compiler/aco_live_var_analysis.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 70ad3a2906b..f5e2e44924f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -6724,7 +6724,7 @@ "description": "aco: summarize register demand after handling branches", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "5a536eca9ca763f53bf3e4c8b75752b527f8fc01", "notes": null 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 */