diff options
author | Daniel Schürmann <daniel@schuermann.dev> | 2022-01-27 13:25:55 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-02-11 19:05:30 +0000 |
commit | d7d7b9974ab3dcaaacfe40478b3530ef848c89fa (patch) | |
tree | cd10df38b5fbad80c214f1acf35aead6d0080d94 /src/amd/compiler/aco_insert_exec_mask.cpp | |
parent | fcc5dec8d6902b737c5f836120b9fca9b0b2df59 (diff) | |
download | mesa-d7d7b9974ab3dcaaacfe40478b3530ef848c89fa.tar.gz |
aco/insert_exec_mask: refactor and simplify get_block_needs()
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>
Diffstat (limited to 'src/amd/compiler/aco_insert_exec_mask.cpp')
-rw-r--r-- | src/amd/compiler/aco_insert_exec_mask.cpp | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/src/amd/compiler/aco_insert_exec_mask.cpp b/src/amd/compiler/aco_insert_exec_mask.cpp index f537ac4015f..f715df08a47 100644 --- a/src/amd/compiler/aco_insert_exec_mask.cpp +++ b/src/amd/compiler/aco_insert_exec_mask.cpp @@ -51,12 +51,9 @@ struct wqm_ctx { Program* program; /* state for WQM propagation */ std::set<unsigned> worklist; - std::vector<uint16_t> defined_in; - std::vector<bool> needs_wqm; std::vector<bool> branch_wqm; /* true if the branch condition in this block should be in wqm */ wqm_ctx(Program* program_) - : program(program_), defined_in(program->peekAllocationId(), 0xFFFF), - needs_wqm(program->peekAllocationId()), branch_wqm(program->blocks.size()) + : program(program_), branch_wqm(program->blocks.size()) { for (unsigned i = 0; i < program->blocks.size(); i++) worklist.insert(i); @@ -128,42 +125,25 @@ get_block_needs(wqm_ctx& ctx, exec_ctx& exec_ctx, Block* block) std::vector<WQMState> instr_needs(block->instructions.size()); + bool propagate_wqm = ctx.branch_wqm[block->index]; for (int i = block->instructions.size() - 1; i >= 0; --i) { aco_ptr<Instruction>& instr = block->instructions[i]; - WQMState needs = needs_exact(instr) ? Exact : Unspecified; - bool propagate_wqm = instr->opcode == aco_opcode::p_wqm; + if (instr->opcode == aco_opcode::p_wqm) + propagate_wqm = true; + bool pred_by_exec = needs_exec_mask(instr.get()) || instr->opcode == aco_opcode::p_logical_end || instr->isBranch(); - for (const Definition& definition : instr->definitions) { - if (!definition.isTemp()) - continue; - const unsigned def = definition.tempId(); - ctx.defined_in[def] = block->index; - if (needs == Unspecified && ctx.needs_wqm[def]) { - needs = pred_by_exec ? WQM : Unspecified; - propagate_wqm = true; - } - } - - if (instr->isBranch()) - propagate_wqm = ctx.branch_wqm[block->index]; - if (propagate_wqm) { - needs = pred_by_exec ? WQM : Unspecified; - for (const Operand& op : instr->operands) { - if (op.isTemp()) { - ctx.needs_wqm[op.tempId()] = true; - } - } - } - if (needs == Unspecified && info.block_needs & WQM) { - needs = pred_by_exec ? WQM : Unspecified; - } + if (needs_exact(instr)) + instr_needs[i] = Exact; + else if (propagate_wqm && pred_by_exec) + instr_needs[i] = WQM; + else + instr_needs[i] = Unspecified; - instr_needs[i] = needs; - info.block_needs |= needs; + info.block_needs |= instr_needs[i]; } info.instr_needs = instr_needs; |