From: Daniel Schürmann Date: Thu, 30 Apr 2020 09:58:08 +0000 (+0100) Subject: nir/algebraic: optimize (a < 0.0) ? -a : a -> fabs(a) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=70d3efeb88c847dbf37ab6bce057a4390e46e027;p=mesa.git nir/algebraic: optimize (a < 0.0) ? -a : a -> fabs(a) 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: --- 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))),