Commit 9ca28799 authored by Rhys Perry's avatar Rhys Perry
Browse files

aco: remove p_wqm during insert_exec_mask

fossil-db (navi21):
Totals from 45334 (33.42% of 135636) affected shaders:
MaxWaves: 1062176 -> 1058940 (-0.30%); split: +0.11%, -0.41%
Instrs: 32600411 -> 32541423 (-0.18%); split: -0.20%, +0.02%
CodeSize: 176449880 -> 175931224 (-0.29%); split: -0.32%, +0.03%
VGPRs: 2074768 -> 2093040 (+0.88%); split: -0.18%, +1.06%
Latency: 445697225 -> 445555067 (-0.03%); split: -0.10%, +0.06%
InvThroughput: 84125135 -> 84512709 (+0.46%); split: -0.22%, +0.68%
VClause: 629965 -> 621630 (-1.32%); split: -1.75%, +0.43%
SClause: 1423941 -> 1415971 (-0.56%); split: -0.84%, +0.28%
Copies: 1871955 -> 1820874 (-2.73%); split: -3.03%, +0.30%
Branches: 652251 -> 652168 (-0.01%); split: -0.02%, +0.01%
PreVGPRs: 1775517 -> 1772710 (-0.16%)

fossil-db (navi21, excluding detroit: become human):
Totals from 37943 (33.14% of 114495) affected shaders:
MaxWaves: 942546 -> 943090 (+0.06%); split: +0.12%, -0.06%
Instrs: 20810132 -> 20765529 (-0.21%); split: -0.24%, +0.03%
CodeSize: 112843980 -> 112508644 (-0.30%); split: -0.34%, +0.04%
VGPRs: 15803048

 -> 1582736 (+0.15%); split: -0.22%, +0.37%
Latency: 282400557 -> 282276594 (-0.04%); split: -0.14%, +0.10%
InvThroughput: 54958538 -> 54814378 (-0.26%); split: -0.32%, +0.06%
VClause: 420666 -> 422099 (+0.34%); split: -0.27%, +0.61%
SClause: 988189 -> 981029 (-0.72%); split: -1.11%, +0.38%
Copies: 1009518 -> 970925 (-3.82%); split: -4.26%, +0.44%
Branches: 306082 -> 306083 (+0.00%); split: -0.01%, +0.01%
PreVGPRs: 1286421 -> 1283757 (-0.21%)

Detroit: Become Human MaxWaves regressions seem to be due to the scheduler
choosing to schedule more aggressively.

Signed-off-by: Rhys Perry's avatarRhys Perry <pendingchaos02@gmail.com>
parent 7201479f
Pipeline #687496 waiting for manual action with stages
......@@ -84,7 +84,14 @@ struct exec_ctx {
std::vector<block_info> info;
std::vector<loop_info> loop;
bool handle_wqm = false;
exec_ctx(Program* program_) : program(program_), info(program->blocks.size()) {}
bool has_renames = false;
std::vector<unsigned> renames;
std::vector<uint32_t> loop_headers;
exec_ctx(Program* program_)
: program(program_), info(program->blocks.size()), renames(program->peekAllocationId())
{}
};
bool
......@@ -240,6 +247,17 @@ transition_to_Exact(exec_ctx& ctx, Builder bld, unsigned idx)
ctx.info[idx].exec.emplace_back(Operand(bld.lm), mask_type_exact);
}
void
rename_operands(exec_ctx& ctx, aco_ptr<Instruction>& instr)
{
for (Operand& op : instr->operands) {
if (op.isTemp() && op.tempId() < ctx.renames.size() && ctx.renames[op.tempId()]) {
unsigned id = ctx.renames[op.tempId()];
op.setTemp(Temp(id, ctx.program->temp_rc[id]));
}
}
}
unsigned
add_coupling_code(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instruction>>& instructions)
{
......@@ -458,6 +476,8 @@ add_coupling_code(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instruction>>
unsigned i = 0;
while (block->instructions[i]->opcode == aco_opcode::p_phi ||
block->instructions[i]->opcode == aco_opcode::p_linear_phi) {
if (ctx.has_renames)
rename_operands(ctx, block->instructions[i]);
bld.insert(std::move(block->instructions[i]));
i++;
}
......@@ -530,6 +550,9 @@ process_instructions(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instructio
for (; idx < block->instructions.size(); idx++) {
aco_ptr<Instruction> instr = std::move(block->instructions[idx]);
if (ctx.has_renames)
rename_operands(ctx, instr);
WQMState needs = ctx.handle_wqm ? ctx.info[block->index].instr_needs[idx] : Unspecified;
if (needs == WQM && state != WQM) {
......@@ -676,10 +699,34 @@ process_instructions(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instructio
}
instr.reset();
continue;
} else if (instr->opcode == aco_opcode::p_wqm && instr->definitions.size() == 1 &&
!instr->definitions[0].isFixed() && instr->operands[0].isTemp() &&
instr->definitions[0].regClass() == instr->operands[0].regClass()) {
/* p_wqm isn't needed anymore, so remove it. */
ctx.has_renames = true;
ctx.renames[instr->definitions[0].tempId()] = instr->operands[0].tempId();
instr.reset();
continue;
}
bld.insert(std::move(instr));
}
if (block->kind & block_kind_loop_exit) {
uint32_t header = ctx.loop_headers.back();
ctx.loop_headers.pop_back();
/* rename loop header phis */
if (ctx.has_renames) {
for (aco_ptr<Instruction>& instr : ctx.program->blocks[header].instructions) {
if (!is_phi(instr))
continue;
rename_operands(ctx, instr);
}
}
} else if (block->kind & block_kind_loop_header) {
ctx.loop_headers.emplace_back(block->index);
}
}
void
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment