nir/opt_algebraic: Add some boolean simplifications
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 29 Jan 2015 00:55:03 +0000 (16:55 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 30 Jan 2015 01:11:10 +0000 (17:11 -0800)
total instructions in shared programs: 5998321 -> 5998287 (-0.00%)
instructions in affected programs:     4520 -> 4486 (-0.75%)
helped:                                8

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/nir/nir_opt_algebraic.py

index 210c40dd15882c247d57ec4777e8d7ab4b41cf28..cf305156c5c100e30ee36b0c4c628268344836bb 100644 (file)
@@ -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@bool', 0), 'a'),
+   (('ieq', 'a@bool', 0), ('inot', 'a')),
+   (('bcsel', 'a@bool', True, False), 'a'),
+   (('bcsel', 'a@bool', False, True), ('inot', 'a')),
 
 # This one may not be exact
    (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),