Mesa (master): nir/algebraic: sqrt(x)*sqrt(x) -> fabs(x)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 15 00:54:16 UTC 2020


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

Author: Elie Tournier <tournier.elie at gmail.com>
Date:   Fri May 24 12:16:25 2019 +0100

nir/algebraic: sqrt(x)*sqrt(x) -> fabs(x)

total instructions in shared programs: 12840840 -> 12839341 (-0.01%)
instructions in affected programs: 122581 -> 121082 (-1.22%)
helped: 559
HURT: 0

total cycles in shared programs: 302505756 -> 302490031 (<.01%)
cycles in affected programs: 2022900 -> 2007175 (-0.78%)
helped: 1090
HURT: 130

Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/948>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/948>

---

 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 73056c3c35c..2e139ebb85f 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -746,6 +746,7 @@ optimizations.extend([
    (('~flog2', ('fpow', a, b)), ('fmul', b, ('flog2', a))),
    (('~fmul', ('fexp2(is_used_once)', a), ('fexp2(is_used_once)', b)), ('fexp2', ('fadd', a, b))),
    (('bcsel', ('flt', a, 0.0), 0.0, ('fsqrt', a)), ('fsqrt', ('fmax', a, 0.0))),
+   (('~fmul', ('fsqrt', a), ('fsqrt', a)), ('fabs',a)),
    # Division and reciprocal
    (('~fdiv', 1.0, a), ('frcp', a)),
    (('fdiv', a, b), ('fmul', a, ('frcp', b)), 'options->lower_fdiv'),



More information about the mesa-commit mailing list