Mesa (master): nir/opt_algebraic: Add some boolean simplifications

Jason Ekstrand jekstrand at kemper.freedesktop.org
Fri Jan 30 01:13:29 UTC 2015


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Jan 28 16:55:03 2015 -0800

nir/opt_algebraic: Add some boolean simplifications

total instructions in shared programs: 5998321 -> 5998287 (-0.00%)
instructions in affected programs:     4520 -> 4486 (-0.75%)
helped:                                8

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/nir/nir_opt_algebraic.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 210c40d..cf30515 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -77,10 +77,6 @@ optimizations = [
    (('inot', ('fge', a, b)), ('flt', a, b)),
    (('inot', ('ilt', a, b)), ('ige', a, b)),
    (('inot', ('ige', a, b)), ('ilt', a, b)),
-   (('ine', ('flt', a, b), 0), ('flt', a, b)),
-   (('ine', ('fge', a, b), 0), ('fge', a, b)),
-   (('ine', ('ilt', a, b), 0), ('ilt', a, b)),
-   (('ine', ('ige', a, b), 0), ('ige', a, b)),
    (('flt', ('fadd', a, b), 0.0), ('flt', a, ('fneg', b))),
    (('fge', ('fadd', a, b), 0.0), ('fge', a, ('fneg', b))),
    (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
@@ -121,6 +117,11 @@ optimizations = [
    (('frcp', ('frcp', a)), a),
    (('frcp', ('fsqrt', a)), ('frsq', a)),
    (('frcp', ('frsq', a)), ('fsqrt', a)),
+   # Boolean simplifications
+   (('ine', 'a at bool', 0), 'a'),
+   (('ieq', 'a at bool', 0), ('inot', 'a')),
+   (('bcsel', 'a at bool', True, False), 'a'),
+   (('bcsel', 'a at bool', False, True), ('inot', 'a')),
 
 # This one may not be exact
    (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),




More information about the mesa-commit mailing list