From f192fe99ebe5c91318063feabe534fa02c33cd4d Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Tue, 31 Mar 2026 16:58:55 +0200 Subject: [PATCH] nir/opt_algebraic: update open coded flerp(..., b2f(c)) to bcsel patterns We remove 1.0 - b2f(a) since 6a662a59b7604c74863cb90c2ddc11a49063dadb. Foz-DB Navi48: Totals from 200 (0.10% of 205032) affected shaders: Instrs: 410309 -> 409750 (-0.14%); split: -0.18%, +0.05% CodeSize: 2140424 -> 2136956 (-0.16%); split: -0.21%, +0.05% Latency: 5834394 -> 5834042 (-0.01%); split: -0.02%, +0.01% InvThroughput: 906879 -> 906374 (-0.06%); split: -0.06%, +0.01% VClause: 8247 -> 8244 (-0.04%) SClause: 7721 -> 7723 (+0.03%); split: -0.03%, +0.05% Copies: 20515 -> 20487 (-0.14%); split: -0.29%, +0.16% PreVGPRs: 14510 -> 14481 (-0.20%) VALU: 228703 -> 228235 (-0.20%); split: -0.28%, +0.07% SALU: 62832 -> 62914 (+0.13%); split: -0.18%, +0.31% VOPD: 929 -> 927 (-0.22%) Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index cc40a86a18d..4f172a1675e 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -466,10 +466,10 @@ for s in [16, 32, 64]: (('~fadd@{}'.format(s), ('fmul', a, ('fsat', ('fadd', 1.0, ('fneg', c)))), ('fmul', b, ('fsat', c))), ('flrp', a, b, ('fsat', c)), '!options->lower_flrp{}'.format(s)), (('~fadd@{}'.format(s), a, ('fmul', c, ('fadd', b, ('fneg', a)))), ('flrp', a, b, c), '!options->lower_flrp{}'.format(s)), - (('~fadd@{}'.format(s), ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', 'c@1')))), ('fmul', b, ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp{}'.format(s)), + (('~fadd@{}'.format(s), ('fmul', a, ('b2f', ('inot', 'c@1'))), ('fmul', b, ('b2f', c))), ('bcsel', c, ('fcanonicalize', b), ('fcanonicalize', a)), 'options->lower_flrp{}'.format(s)), (('~fadd@{}'.format(s), a, ('fmul', ('b2f', 'c@1'), ('fadd', b, ('fneg', a)))), ('bcsel', c, ('fcanonicalize', b), ('fcanonicalize', a)), 'options->lower_flrp{}'.format(s)), - (('~ffma@{}'.format(s), a, ('fadd', 1.0, ('fneg', ('b2f', 'c@1'))), ('fmul', b, ('b2f', 'c@1'))), ('bcsel', c, ('fcanonicalize', b), ('fcanonicalize', a))), + (('~ffma@{}'.format(s), a, ('b2f', ('inot', 'c@1')), ('fmul', b, ('b2f', 'c@1'))), ('bcsel', c, ('fcanonicalize', b), ('fcanonicalize', a))), (('~ffma@{}'.format(s), b, ('b2f', 'c@1'), ('ffma', ('fneg', a), ('b2f', 'c@1'), a)), ('bcsel', c, ('fcanonicalize', b), ('fcanonicalize', a))), # These two aren't flrp lowerings, but do appear in some shaders.