Mesa (master): nir: Recognize sat(add(b2f(a), b2f(b))) as a logical OR.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Mar 24 21:45:16 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue Mar 17 23:30:43 2015 -0700

nir: Recognize sat(add(b2f(a), b2f(b))) as a logical OR.

Transform this into b2f(or(a, b)).

instructions in affected programs:     432 -> 430 (-0.46%)
helped:                                2

Acked-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

---

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

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index f956edf..1ee51a0 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -97,6 +97,7 @@ optimizations = [
    (('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)),
    # Emulating booleans
    (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
+   (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
    # Comparison with the same args.  Note that these are not done for
    # the float versions because NaN always returns false on float
    # inequalities.




More information about the mesa-commit mailing list