From 6eb4dfca2344d123c1d7115e68d5a208ebbaba83 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 19 Aug 2022 17:47:43 +0200 Subject: [PATCH] nir/opt_algebraic: Optimize d3d9 pow with fmulz. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi21: Totals from 69 (0.05% of 134913) affected shaders: CodeSize: 255684 -> 253788 (-0.74%); split: -0.74%, +0.00% Instrs: 46307 -> 46052 (-0.55%); split: -0.55%, +0.00% Latency: 533255 -> 530742 (-0.47%); split: -0.48%, +0.01% InvThroughput: 110001 -> 109156 (-0.77%) VClause: 839 -> 844 (+0.60%); split: -1.19%, +1.79% SClause: 1411 -> 1395 (-1.13%) Copies: 1828 -> 1816 (-0.66%); split: -1.09%, +0.44% PreSGPRs: 2243 -> 2232 (-0.49%) PreVGPRs: 2213 -> 2192 (-0.95%) Signed-off-by: Georg Lehmann Reviewed-by: Daniel Schürmann 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 414d1291276..1a782bc9d23 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -276,6 +276,11 @@ optimizations = [ ('ffmaz', a, b, c), 'options->has_fmulz && !'+signed_zero_inf_nan_preserve_32), (('ffma@32', a, ('bcsel', ignore_exact('feq', a, 0.0), 0.0, '#b(is_not_const_zero)'), c), ('ffmaz', a, b, c), 'options->has_fmulz && !'+signed_zero_inf_nan_preserve_32), + + # b == 0.0 ? 1.0 : fexp2(fmul(a, b)) -> fexp2(fmulz(a, b)) + (('bcsel', ignore_exact('feq', b, 0.0), 1.0, ('fexp2', ('fmul@32', a, b))), + ('fexp2', ('fmulz', a, b)), + 'options->has_fmulz && !'+signed_zero_inf_nan_preserve_32), ] # Shorthand for the expansion of just the dot product part of the [iu]dp4a