Mesa (master): nir: Add algebraic optimizations for pointless shifts.

Kenneth Graunke kwg at kemper.freedesktop.org
Fri Jan 23 22:55:23 UTC 2015


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Jan 21 23:25:56 2015 -0800

nir: Add algebraic optimizations for pointless shifts.

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

v2: Fix a >> 0 and a << 0 optimizations (caught by Matt).

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

total i965 instructions in shared programs: 6035397 -> 6035392 (-0.00%)
i965 instructions in affected programs:     542 -> 537 (-0.92%)
helped:                                     2 (in glamor)

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 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 53fe4a0..be94870 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -80,6 +80,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), a),
+   (('ishr', 0, a), 0),
+   (('ishr', a, 0), a),
+   (('ushr', 0, a), 0),
+   (('ushr', a, 0), 0),
 
 # This one may not be exact
    (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),




More information about the mesa-commit mailing list