[Mesa-dev] [PATCH 07/10] nir: Add algebraic optimizations for pointless shifts.

Kenneth Graunke kenneth at whitecape.org
Thu Jan 22 03:41:28 PST 2015


The GLSL IR optimization pass contained these; we may as well include
them too.

No change in the number of NIR instructions on a shader-db run.

total i965 instructions in shared programs: 6035397 -> 6035393 (-0.00%)
i965 instructions in affected programs:     772 -> 768 (-0.52%)
helped:                                     3 (all in glamor)

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/nir/nir_opt_algebraic.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index cf16b19..58e71e0 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -83,6 +83,13 @@ optimizations = [
    # DeMorgan's Laws
    (('iand', ('inot', a), ('inot', b)), ('inot', ('ior',  a, b))),
    (('ior',  ('inot', a), ('inot', b)), ('inot', ('iand', a, b))),
+   # Shift optimizations
+   (('ishl', 0, a), 0),
+   (('ishl', a, 0), 0),
+   (('ishr', 0, a), 0),
+   (('ishr', a, 0), 0),
+   (('ushr', 0, a), 0),
+   (('ushr', a, 0), 0),
 
 # 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