aco: summarize register demand after handling branches

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 <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Fixes: 5a536eca9c ("aco: calculate correct register demand for branch instructions")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24579>
(cherry picked from commit efb80c1715)
This commit is contained in:
Rhys Perry 2023-08-08 21:02:21 +01:00 committed by Dylan Baker
parent 8dab73cab2
commit 34b2f00d9c
2 changed files with 10 additions and 10 deletions

View file

@ -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

View file

@ -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(&register_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 */