From 70d3efeb88c847dbf37ab6bce057a4390e46e027 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 30 Apr 2020 10:58:08 +0100 Subject: [PATCH] nir/algebraic: optimize (a < 0.0) ? -a : a -> fabs(a) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Totals from affected shaders: (VEGA) SGPRS: 13920 -> 13920 (0.00 %) VGPRS: 10252 -> 10252 (0.00 %) Spilled SGPRs: 62 -> 62 (0.00 %) Spilled VGPRs: 0 -> 0 (0.00 %) Private memory VGPRs: 0 -> 0 (0.00 %) Scratch size: 0 -> 0 (0.00 %) dwords per thread Code Size: 587648 -> 587224 (-0.07 %) bytes LDS: 5 -> 5 (0.00 %) blocks Max Waves: 1489 -> 1489 (0.00 %) Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rhys Perry Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index bd84966821a..bd0da989c9e 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1136,6 +1136,7 @@ optimizations.extend([ (('~fmul', ('bcsel(is_used_once)', c, -1.0, 1.0), b), ('bcsel', c, ('fneg', b), b)), (('~fmul', ('bcsel(is_used_once)', c, 1.0, -1.0), b), ('bcsel', c, b, ('fneg', b))), + (('~bcsel', ('flt', a, 0.0), ('fneg', a), a), ('fabs', a)), (('fmin3@64', a, b, c), ('fmin@64', a, ('fmin@64', b, c))), (('fmax3@64', a, b, c), ('fmax@64', a, ('fmax@64', b, c))), -- 2.30.2