From cf5f9854bcb414b07cf1a6318cf6066a228b0a07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 24 Aug 2022 15:12:40 +0200 Subject: [PATCH] aco/optimizer: optimize s_and(exec, s_and(x, y)) more aggressively MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It is enough if either of the two operands is respecting the current exec mask. Totals from 1680 (1.25% of 134913) affected shaders: (GFX10.3) CodeSize: 3929436 -> 3922372 (-0.18%); split: -0.18%, +0.00% Instrs: 730305 -> 728536 (-0.24%); split: -0.24%, +0.00% Latency: 6839314 -> 6835154 (-0.06%); split: -0.07%, +0.01% InvThroughput: 1371351 -> 1371267 (-0.01%); split: -0.01%, +0.00% SClause: 32819 -> 32802 (-0.05%); split: -0.09%, +0.04% Copies: 33264 -> 33271 (+0.02%); split: -0.01%, +0.03% Reviewed-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_optimizer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index be19e59..493738a 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -1218,8 +1218,13 @@ can_eliminate_and_exec(opt_ctx& ctx, Temp tmp, unsigned pass_flags) return false; if (!(instr->operands[0].isTemp() && instr->operands[1].isTemp())) return false; - return can_eliminate_and_exec(ctx, instr->operands[0].getTemp(), pass_flags) && - can_eliminate_and_exec(ctx, instr->operands[1].getTemp(), pass_flags); + if (instr->opcode == aco_opcode::s_and_b32 || instr->opcode == aco_opcode::s_and_b64) { + return can_eliminate_and_exec(ctx, instr->operands[0].getTemp(), pass_flags) || + can_eliminate_and_exec(ctx, instr->operands[1].getTemp(), pass_flags); + } else { + return can_eliminate_and_exec(ctx, instr->operands[0].getTemp(), pass_flags) && + can_eliminate_and_exec(ctx, instr->operands[1].getTemp(), pass_flags); + } } return false; } -- 2.7.4