From ef7dd040d9c6cfbac668d71f8498d5d433dcbf9d Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sun, 1 Feb 2026 17:54:26 +0100 Subject: [PATCH] nir/opt_algebraic: make a < 0.0 ? -a : a exact using search helpers Foz-DB Navi21: Totals from 104 (0.13% of 82405) affected shaders: Instrs: 175964 -> 175514 (-0.26%); split: -0.26%, +0.00% CodeSize: 909008 -> 908744 (-0.03%); split: -0.05%, +0.02% Latency: 1515203 -> 1514560 (-0.04%); split: -0.05%, +0.01% InvThroughput: 308751 -> 308573 (-0.06%); split: -0.06%, +0.00% Copies: 10318 -> 10315 (-0.03%); split: -0.06%, +0.03% PreVGPRs: 5767 -> 5755 (-0.21%) VALU: 108151 -> 107745 (-0.38%) VOPD: 738 -> 737 (-0.14%) Reviewed-by: Rhys Perry Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index d8c515c7999..59db4c7fb70 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2439,7 +2439,7 @@ optimizations.extend([ (('fmulz(nsz)', ('bcsel(is_used_once)', c, 1.0, -1.0), b), ('bcsel', c, ('fcanonicalize', b), ('fneg', b))), (('fabs', ('bcsel(is_used_once)', b, ('fneg', a), a)), ('fabs', a)), (('fabs', ('bcsel(is_used_once)', b, a, ('fneg', a))), ('fabs', a)), - (('~bcsel', ('flt', a, 0.0), ('fneg', a), a), ('fabs', a)), + (('bcsel(is_only_used_as_float_nsz)', ('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)),