Mesa (staging/21.1): aco: don't update register demand during RA validation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 21 19:46:41 UTC 2021
Module: Mesa
Branch: staging/21.1
Commit: 7ab251c71ac353f56a12353b7d4826db041ab793
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ab251c71ac353f56a12353b7d4826db041ab793
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>
(cherry picked from commit 655ba1e3a9b2a1acbf56937c39a1bd25d48d0246)
---
.pick_status.json | 2 +-
src/amd/compiler/aco_ir.h | 2 +-
src/amd/compiler/aco_live_var_analysis.cpp | 19 ++++++++++++-------
src/amd/compiler/aco_validate.cpp | 2 +-
4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 242a4163ea0..495ebed8f08 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -256,7 +256,7 @@
"description": "aco: don't update register demand during RA validation",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
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 5fe6c58dc8d..5f586dccb74 100644
--- a/src/amd/compiler/aco_validate.cpp
+++ b/src/amd/compiler/aco_validate.cpp
@@ -677,7 +677,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