From 0bc1bffe9abf61d9b12af8d3c351464281e5deb6 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 5 Feb 2025 19:13:13 +0100 Subject: [PATCH] nir/opt_move: don't move into critical sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi31: Totals from 6694 (8.43% of 79377) affected shaders: Instrs: 4125152 -> 4119037 (-0.15%); split: -0.16%, +0.01% CodeSize: 22786832 -> 22761612 (-0.11%); split: -0.12%, +0.01% Latency: 23343080 -> 23270421 (-0.31%); split: -0.32%, +0.01% InvThroughput: 3449821 -> 3449859 (+0.00%); split: -0.00%, +0.00% SClause: 176624 -> 176219 (-0.23%); split: -0.23%, +0.00% Copies: 256709 -> 255739 (-0.38%) PreVGPRs: 240038 -> 240251 (+0.09%) SALU: 336732 -> 334794 (-0.58%) Foz-DB Navi21: Totals from 11227 (14.14% of 79377) affected shaders: MaxWaves: 279804 -> 279796 (-0.00%) Instrs: 6652332 -> 6650912 (-0.02%); split: -0.02%, +0.00% CodeSize: 35974500 -> 35968152 (-0.02%); split: -0.02%, +0.00% VGPRs: 491440 -> 491512 (+0.01%); split: -0.00%, +0.02% Latency: 34291475 -> 34247972 (-0.13%); split: -0.15%, +0.02% InvThroughput: 7603701 -> 7603724 (+0.00%); split: -0.00%, +0.00% VClause: 132041 -> 132068 (+0.02%); split: -0.00%, +0.02% SClause: 239880 -> 239438 (-0.18%); split: -0.20%, +0.01% Copies: 530000 -> 529986 (-0.00%); split: -0.00%, +0.00% PreVGPRs: 393471 -> 394170 (+0.18%); split: -0.00%, +0.18% VALU: 4274980 -> 4274966 (-0.00%); split: -0.00%, +0.00% Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_move.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_move.c b/src/compiler/nir/nir_opt_move.c index efdf344697b..9a3cb95b96d 100644 --- a/src/compiler/nir/nir_opt_move.c +++ b/src/compiler/nir/nir_opt_move.c @@ -71,8 +71,18 @@ nir_opt_move_block(nir_block *block, nir_move_options options) instr->index = index++; /* Check if this instruction can be moved downwards */ - if (!nir_can_move_instr(instr, options)) + if (!nir_can_move_instr(instr, options)) { + if (instr->type == nir_instr_type_intrinsic) { + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); + if (intrin->intrinsic == nir_intrinsic_export_amd || + intrin->intrinsic == nir_intrinsic_export_row_amd || + intrin->intrinsic == nir_intrinsic_begin_invocation_interlock) { + /* Moving past these increases a critical section. */ + last_instr = instr; + } + } continue; + } /* Check all users in this block which is the first */ const nir_def *def = nir_instr_def(instr);