From d6535f260218f644e0f99312c6df67b2c93f3a5f Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 25 Oct 2024 19:52:55 +0200 Subject: [PATCH] nir/opt_algebraic: create ubfe with non constant mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi21: Totals from 278 (0.35% of 79395) affected shaders: MaxWaves: 7444 -> 7448 (+0.05%) Instrs: 316069 -> 314584 (-0.47%); split: -0.47%, +0.00% CodeSize: 1608064 -> 1593204 (-0.92%) VGPRs: 11128 -> 11120 (-0.07%) Latency: 796599 -> 797786 (+0.15%); split: -0.19%, +0.34% InvThroughput: 141195 -> 139472 (-1.22%); split: -1.22%, +0.00% Copies: 28565 -> 29796 (+4.31%); split: -0.15%, +4.46% PreSGPRs: 14335 -> 14336 (+0.01%) VALU: 161342 -> 159426 (-1.19%) SALU: 87794 -> 88305 (+0.58%); split: -0.03%, +0.61% Reviewed-by: Ian Romanick Reviewed-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 68ed6e30e7c..57f7f34b82d 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -562,6 +562,12 @@ optimizations.extend([ ('ubfe', a, b, ('bit_count', c)), 'options->has_bfe && !options->avoid_ternary_with_two_constants'), + (('iand@32', ('ushr@32', a, b), ('bfm', c, 0)), + ('ubfe', a, b, c), 'options->has_bfe'), + + (('ushr', ('iand', a, ('bfm', c, b)), b), + ('ubfe', a, b, c), 'options->has_bfe'), + # Collapse two bitfield extracts with constant operands into a single one. (('ubfe', ('ubfe', a, '#b', '#c'), '#d', '#e'), ubfe_ubfe(a, b, c, d, e)),