Mesa (master): nir/algebraic: optimize (a < 0.0) ? -a : a -> fabs(a)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 20 16:31:07 UTC 2020


Module: Mesa
Branch: master
Commit: 70d3efeb88c847dbf37ab6bce057a4390e46e027
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=70d3efeb88c847dbf37ab6bce057a4390e46e027

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Thu Apr 30 10:58:08 2020 +0100

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 <alyssa.rosenzweig at collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4830>

---

 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 at 64', a, b, c), ('fmin at 64', a, ('fmin at 64', b, c))),
    (('fmax3 at 64', a, b, c), ('fmax at 64', a, ('fmax at 64', b, c))),



More information about the mesa-commit mailing list