From 4c7d6e9437d98ce7c7f2de893fe1a23d6f47cff1 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 19 Nov 2024 14:53:38 +0000 Subject: [PATCH] nir/algebraic: optimize more bcsel(, bcsel()) This inot should be pretty optimizable. fossil-db (navi21); Totals from 2361 (2.97% of 79395) affected shaders: MaxWaves: 50808 -> 50890 (+0.16%) Instrs: 4168195 -> 4167332 (-0.02%); split: -0.05%, +0.03% CodeSize: 22727496 -> 22708088 (-0.09%); split: -0.12%, +0.03% VGPRs: 135160 -> 134824 (-0.25%) SpillSGPRs: 723 -> 725 (+0.28%) Latency: 37498671 -> 37479794 (-0.05%); split: -0.07%, +0.02% InvThroughput: 10468406 -> 10453028 (-0.15%); split: -0.16%, +0.01% VClause: 98258 -> 98283 (+0.03%); split: -0.04%, +0.07% SClause: 111281 -> 111323 (+0.04%); split: -0.06%, +0.09% Copies: 299281 -> 300155 (+0.29%); split: -0.17%, +0.46% Branches: 115951 -> 116111 (+0.14%); split: -0.00%, +0.14% PreSGPRs: 109404 -> 109462 (+0.05%); split: -0.14%, +0.19% PreVGPRs: 114558 -> 114421 (-0.12%) VALU: 2876823 -> 2869990 (-0.24%); split: -0.24%, +0.00% SALU: 500286 -> 506124 (+1.17%); split: -0.03%, +1.20% Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 73447441b27..6add5f1423e 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2155,7 +2155,9 @@ optimizations.extend([ (('~bcsel', ('flt', a, 0.0), ('fneg', a), a), ('fabs', a)), (('bcsel', a, ('bcsel(is_used_once)', b, c, d), d), ('bcsel', ('iand', a, b), c, d)), + (('bcsel', a, ('bcsel(is_used_once)', b, d, c), d), ('bcsel', ('iand', a, ('inot', b)), c, d)), (('bcsel', a, b, ('bcsel(is_used_once)', c, b, d)), ('bcsel', ('ior', a, c), b, d)), + (('bcsel', a, b, ('bcsel(is_used_once)', c, d, b)), ('bcsel', ('iand', c, ('inot', a)), d, b)), # Misc. lowering (('fmod', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b)))), 'options->lower_fmod'),