Mesa (master): aco: don't update register demand during RA validation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 21 11:23:46 UTC 2021
Module: Mesa
Branch: master
Commit: 655ba1e3a9b2a1acbf56937c39a1bd25d48d0246
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=655ba1e3a9b2a1acbf56937c39a1bd25d48d0246
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Mon Apr 19 11:24:03 2021 +0100
aco: don't update register demand during RA validation
It isn't intended to be accurate after RA, so num_waves can become zero,
breaking the sgpr_limit calculation.
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10315>
---
src/amd/compiler/aco_ir.h | 2 +-
src/amd/compiler/aco_live_var_analysis.cpp | 19 ++++++++++++-------
src/amd/compiler/aco_validate.cpp | 2 +-
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h
index 4572fcdac63..89ff0b96273 100644
--- a/src/amd/compiler/aco_ir.h
+++ b/src/amd/compiler/aco_ir.h
@@ -1983,7 +1983,7 @@ void select_trap_handler_shader(Program *program, struct nir_shader *shader,
void lower_phis(Program* program);
void calc_min_waves(Program* program);
void update_vgpr_sgpr_demand(Program* program, const RegisterDemand new_demand);
-live live_var_analysis(Program* program);
+live live_var_analysis(Program* program, bool update_register_demand=true);
std::vector<uint16_t> dead_code_analysis(Program *program);
void dominator_tree(Program* program);
void insert_exec_mask(Program *program);
diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp
index 6dd81398b9d..86a49ecf6b0 100644
--- a/src/amd/compiler/aco_live_var_analysis.cpp
+++ b/src/amd/compiler/aco_live_var_analysis.cpp
@@ -82,13 +82,14 @@ RegisterDemand get_demand_before(RegisterDemand demand, aco_ptr<Instruction>& in
namespace {
void process_live_temps_per_block(Program *program, live& lives, Block* block,
- std::set<unsigned>& worklist, std::vector<uint16_t>& phi_sgpr_ops)
+ std::set<unsigned>& worklist, std::vector<uint16_t>& phi_sgpr_ops,
+ bool update_register_demand)
{
std::vector<RegisterDemand>& register_demand = lives.register_demand[block->index];
RegisterDemand new_demand;
register_demand.resize(block->instructions.size());
- block->register_demand = RegisterDemand();
+ RegisterDemand block_register_demand;
IDSet live = lives.live_out[block->index];
/* initialize register demand */
@@ -159,11 +160,13 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
}
}
- block->register_demand.update(register_demand[idx]);
+ block_register_demand.update(register_demand[idx]);
}
/* update block's register demand for a last time */
- block->register_demand.update(new_demand);
+ block_register_demand.update(new_demand);
+ if (update_register_demand)
+ block->register_demand = block_register_demand;
/* handle phi definitions */
int phi_idx = idx;
@@ -362,7 +365,7 @@ void update_vgpr_sgpr_demand(Program* program, const RegisterDemand new_demand)
}
}
-live live_var_analysis(Program* program)
+live live_var_analysis(Program* program, bool update_register_demand)
{
live result;
result.live_out.resize(program->blocks.size());
@@ -380,12 +383,14 @@ live live_var_analysis(Program* program)
std::set<unsigned>::reverse_iterator b_it = worklist.rbegin();
unsigned block_idx = *b_it;
worklist.erase(block_idx);
- process_live_temps_per_block(program, result, &program->blocks[block_idx], worklist, phi_sgpr_ops);
+ process_live_temps_per_block(program, result, &program->blocks[block_idx], worklist,
+ phi_sgpr_ops, update_register_demand);
new_demand.update(program->blocks[block_idx].register_demand);
}
/* calculate the program's register demand and number of waves */
- update_vgpr_sgpr_demand(program, new_demand);
+ if (update_register_demand)
+ update_vgpr_sgpr_demand(program, new_demand);
return result;
}
diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp
index bd77c0c3445..5d81eb0a36c 100644
--- a/src/amd/compiler/aco_validate.cpp
+++ b/src/amd/compiler/aco_validate.cpp
@@ -679,7 +679,7 @@ bool validate_ra(Program *program) {
return false;
bool err = false;
- aco::live live_vars = aco::live_var_analysis(program);
+ aco::live live_vars = aco::live_var_analysis(program, false);
std::vector<std::vector<Temp>> phi_sgpr_ops(program->blocks.size());
uint16_t sgpr_limit = get_addr_sgpr_from_waves(program, program->num_waves);
More information about the mesa-commit
mailing list