Mesa (master): nir: Optimize (a*b)+(a*c) -> a*(b+c)

Matt Turner mattst88 at kemper.freedesktop.org
Wed Mar 11 21:21:16 UTC 2015


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

Author: Thomas Helland <thomashelland90 at gmail.com>
Date:   Sat Feb 28 20:32:31 2015 +0100

nir: Optimize (a*b)+(a*c) -> a*(b+c)

Shader-db i965 instructions:
total instructions in shared programs: 1715894 -> 1710802 (-0.30%)
instructions in affected programs:     443080 -> 437988 (-1.15%)
helped:                                1502
HURT:                                  13
GAINED:                                4
LOST:                                  4

Shader-db NIR instructions:
total instructions in shared programs: 607710 -> 606187 (-0.25%)
instructions in affected programs:     208285 -> 206762 (-0.73%)
helped:                                769
HURT:                                  8
GAINED:                                0
LOST:                                  0

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>

---

 src/glsl/nir/nir_opt_algebraic.py |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 7bf6431..688ceff 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -56,6 +56,8 @@ optimizations = [
    (('iabs', ('ineg', a)), ('iabs', a)),
    (('fadd', a, 0.0), a),
    (('iadd', a, 0), a),
+   (('fadd', ('fmul', a, b), ('fmul', a, c)), ('fmul', a, ('fadd', b, c))),
+   (('iadd', ('imul', a, b), ('imul', a, c)), ('imul', a, ('iadd', b, c))),
    (('fmul', a, 0.0), 0.0),
    (('imul', a, 0), 0),
    (('fmul', a, 1.0), a),




More information about the mesa-commit mailing list