From bc3b09c5dd2e3b12d7493e415c7695420d39e6fc Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 1 Aug 2025 21:42:36 +0200 Subject: [PATCH] nir/opt_algebraic: optimize pack_half_rtz of bcsel with constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi21: Totals from 448 (0.56% of 80255) affected shaders: Instrs: 345474 -> 344791 (-0.20%); split: -0.20%, +0.00% CodeSize: 1917784 -> 1913324 (-0.23%); split: -0.25%, +0.02% VGPRs: 22344 -> 22416 (+0.32%) Latency: 2320847 -> 2318161 (-0.12%); split: -0.13%, +0.01% InvThroughput: 543008 -> 541722 (-0.24%) SClause: 11450 -> 11459 (+0.08%) Copies: 19991 -> 19949 (-0.21%); split: -0.23%, +0.02% PreSGPRs: 19129 -> 19114 (-0.08%) PreVGPRs: 19695 -> 19696 (+0.01%); split: -0.01%, +0.01% VALU: 257627 -> 256948 (-0.26%) SALU: 30432 -> 30422 (-0.03%) Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 4d70442dcaf..84fc1232b24 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3028,6 +3028,11 @@ optimizations += [ (('pack_half_2x16_rtz_split', ('fneg(is_used_once)', ('fmin(is_used_once)', a, '#b')), ('fneg(is_used_once)', ('fmin(is_used_once)', c, '#d'))), ('pack_32_2x16', ('fmax', ('fneg', ('unpack_32_2x16', ('pack_half_2x16_rtz_split', a, c))), ('fneg', ('unpack_32_2x16', ('pack_half_2x16_rtz_split', b, d))))), 'options->vectorize_vec2_16bit'), + + (('pack_half_2x16_rtz_split', ('bcsel(is_used_once)', a, b, '#c'), ('bcsel(is_used_once)', a, d, '#e')), + ('bcsel', a, ('pack_half_2x16_rtz_split', b, d), ('pack_half_2x16_rtz_split', c, e))), + (('pack_half_2x16_rtz_split', ('bcsel(is_used_once)', a, '#b', c), ('bcsel(is_used_once)', a, '#d', e)), + ('bcsel', a, ('pack_half_2x16_rtz_split', b, d), ('pack_half_2x16_rtz_split', c, e))), ] # Some operations such as iadd have the property that the bottom N bits of the