From cb81ec7a61fb41dd51bc3e1a22efffb4c1492086 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 26 Apr 2024 11:52:13 +0100 Subject: [PATCH] aco: don't count certain pseudo towards VMEM_STORE_CLAUSE_MAX_GRAB_DIST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fossil-db (navi31): Totals from 1023 (1.29% of 79395) affected shaders: MaxWaves: 29258 -> 29240 (-0.06%) Instrs: 1134024 -> 1133163 (-0.08%); split: -0.10%, +0.02% CodeSize: 5682108 -> 5678696 (-0.06%); split: -0.08%, +0.02% VGPRs: 60248 -> 60272 (+0.04%); split: -0.08%, +0.12% Latency: 3797510 -> 3792797 (-0.12%); split: -0.18%, +0.05% InvThroughput: 781270 -> 781239 (-0.00%); split: -0.03%, +0.03% VClause: 24701 -> 23976 (-2.94%); split: -3.55%, +0.61% Copies: 75177 -> 75169 (-0.01%); split: -0.20%, +0.19% VALU: 659939 -> 659962 (+0.00%); split: -0.02%, +0.02% VOPD: 2040 -> 2009 (-1.52%); split: +0.29%, -1.81% Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_scheduler.cpp | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_scheduler.cpp b/src/amd/compiler/aco_scheduler.cpp index 004d442b6f9..3bb119f5e43 100644 --- a/src/amd/compiler/aco_scheduler.cpp +++ b/src/amd/compiler/aco_scheduler.cpp @@ -665,6 +665,34 @@ perform_hazard_query(hazard_query* query, Instruction* instr, bool upwards) return hazard_success; } +unsigned +get_likely_cost(Instruction* instr) +{ + if (instr->opcode == aco_opcode::p_split_vector || + instr->opcode == aco_opcode::p_extract_vector) { + unsigned cost = 0; + for (Definition def : instr->definitions) { + if (instr->operands[0].isKill() && + def.regClass().type() == instr->operands[0].regClass().type()) + continue; + cost += def.size(); + } + return cost; + } else if (instr->opcode == aco_opcode::p_create_vector) { + unsigned cost = 0; + for (Operand op : instr->operands) { + if (op.isTemp() && op.isFirstKill() && + op.regClass().type() == instr->definitions[0].regClass().type()) + continue; + cost += op.size(); + } + return cost; + } else { + /* For the moment, just assume the same cost for all other instructions. */ + return 1; + } +} + void schedule_SMEM(sched_ctx& ctx, Block* block, std::vector& register_demand, Instruction* current, int idx) @@ -1118,7 +1146,7 @@ schedule_VMEM_store(sched_ctx& ctx, Block* block, std::vector& r DownwardsCursor cursor = ctx.mv.downwards_init(idx, true, true); int skip = 0; - for (int i = 0; (i - skip) < VMEM_STORE_CLAUSE_MAX_GRAB_DIST; i++) { + for (int16_t k = 0; k < VMEM_STORE_CLAUSE_MAX_GRAB_DIST;) { aco_ptr& candidate = block->instructions[cursor.source_idx]; if (candidate->opcode == aco_opcode::p_logical_start) break; @@ -1126,6 +1154,7 @@ schedule_VMEM_store(sched_ctx& ctx, Block* block, std::vector& r if (!should_form_clause(current, candidate.get())) { add_to_hazard_query(&hq, candidate.get()); ctx.mv.downwards_skip(cursor); + k += get_likely_cost(candidate.get()); continue; }