From 6121497228d7388a5711c9458945b5903c401c7e Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 12 Feb 2024 11:56:44 +0100 Subject: [PATCH] aco/gfx11+: limit hard clauses to 32 instructions https://github.com/llvm/llvm-project/pull/81287 Foz-DB Navi31: Totals from 406 (0.52% of 78112) affected shaders: Instrs: 585342 -> 585750 (+0.07%) CodeSize: 3077856 -> 3079456 (+0.05%); split: -0.00%, +0.05% Latency: 3263165 -> 3263326 (+0.00%); split: -0.00%, +0.01% InvThroughput: 664092 -> 664114 (+0.00%); split: -0.00%, +0.00% VClause: 11143 -> 11537 (+3.54%) SClause: 11878 -> 11884 (+0.05%) Copies: 39807 -> 39815 (+0.02%) Cc: mesa-stable Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_form_hard_clauses.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_form_hard_clauses.cpp b/src/amd/compiler/aco_form_hard_clauses.cpp index 90ace0b9fb8..66f0ded6f8d 100644 --- a/src/amd/compiler/aco_form_hard_clauses.cpp +++ b/src/amd/compiler/aco_form_hard_clauses.cpp @@ -248,6 +248,10 @@ get_type(Program* program, aco_ptr& instr) void form_hard_clauses(Program* program) { + /* The ISA documentation says 63 is the maximum for GFX11/12, but according to + * LLVM there are HW bugs with more than 32 instructions. + */ + const unsigned max_clause_length = program->gfx_level >= GFX11 ? 32 : 63; for (Block& block : program->blocks) { unsigned num_instrs = 0; aco_ptr current_instrs[63]; @@ -261,7 +265,7 @@ form_hard_clauses(Program* program) aco_ptr& instr = block.instructions[i]; clause_type type = get_type(program, instr); - if (type != current_type || num_instrs == 63 || + if (type != current_type || num_instrs == max_clause_length || (num_instrs && !should_form_clause(current_instrs[0].get(), instr.get()))) { emit_clause(bld, num_instrs, current_instrs); num_instrs = 0;