[Mesa-dev] [PATCH 6/7] nir/opt_algebraic: Add some boolean simplifications

Jason Ekstrand jason at jlekstrand.net
Thu Jan 29 12:50:21 PST 2015


total instructions in shared programs: 8026509 -> 8026469 (-0.00%)
instructions in affected programs:     6338 -> 6298 (-0.63%)
helped:                                11
---
 src/glsl/nir/nir_opt_algebraic.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 1dea42a..e3b309c 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -117,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))),
-- 
2.2.2



More information about the mesa-dev mailing list