From 5d02eae052cc975e7738d3ed037521a6369377d8 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 29 Oct 2025 20:34:33 +0100 Subject: [PATCH] aco/optimizer: add less agressive pattern matching option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still a bit more aggresive than the classic is_used_once, but it should still prevent most regressions for patterns that use min/max/mul as outer instruction. Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_optimizer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 25914429f48..b8e4933bb49 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -3288,6 +3288,11 @@ struct combine_instr_pattern { unsigned operand_mask; const char* swizzle; combine_instr_callback callback; + + /* Limit to pattern matching to avoid unlike combining for instructions + * that might be used as src_opcode for other patterns. + */ + bool less_aggressive; }; bool @@ -3372,6 +3377,9 @@ match_and_apply_patterns(opt_ctx& ctx, alu_opt_info& info, op_instr.opcode != pattern.src_opcode) continue; + if (pattern.less_aggressive && ctx.uses[tmp.id()] > ctx.uses[info.defs[0].tempId()]) + continue; + alu_opt_info new_info = info; unsigned rem = info.operands.size() - 1;