[Mesa-dev] [PATCH 4/8] nir: Add identities for the log function.

Matt Turner mattst88 at gmail.com
Thu Mar 26 12:27:04 PDT 2015


The rcp(log(x)) pattern affects instruction counts.

instructions in affected programs:     144 -> 138 (-4.17%)
helped:                                6
---
 src/glsl/nir/nir_opt_algebraic.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 4fe4cc0..6730408 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -141,6 +141,14 @@ optimizations = [
    (('frcp', ('fexp', a)), ('fexp', ('fneg', a))),
    (('frsq', ('fexp2', a)), ('fexp2', ('fmul', -0.5, a))),
    (('frsq', ('fexp', a)), ('fexp', ('fmul', -0.5, a))),
+   (('flog2', ('fsqrt', a)), ('fmul', 0.5, ('flog2', a))),
+   (('flog', ('fsqrt', a)), ('fmul', 0.5, ('flog', a))),
+   (('flog2', ('frcp', a)), ('fneg', ('flog2', a))),
+   (('flog', ('frcp', a)), ('fneg', ('flog', a))),
+   (('flog2', ('frsq', a)), ('fmul', -0.5, ('flog2', a))),
+   (('flog', ('frsq', a)), ('fmul', -0.5, ('flog', a))),
+   (('flog2', ('fpow', a, b)), ('fmul', b, ('flog2', a))),
+   (('flog', ('fpow', a, b)), ('fmul', b, ('flog', a))),
    # Division and reciprocal
    (('fdiv', 1.0, a), ('frcp', a)),
    (('frcp', ('frcp', a)), a),
-- 
2.0.5



More information about the mesa-dev mailing list