Mesa (master): nir: optimize iand(ieq(a, 0), ieq(b, 0)) to ieq(ior(a, b), 0)

Samuel Pitoiset hakzsam at kemper.freedesktop.org
Thu May 31 08:58:10 UTC 2018


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

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed May 30 10:48:31 2018 +0200

nir: optimize iand(ieq(a, 0), ieq(b, 0)) to ieq(ior(a, b), 0)

Totals from affected shaders:
SGPRS: 80 -> 80 (0.00 %)
VGPRS: 48 -> 48 (0.00 %)
Code Size: 2120 -> 2096 (-1.13 %) bytes
Max Waves: 16 -> 16 (0.00 %)

Only two Rise of Tomb Raider shaders are affected on my side.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/compiler/nir/nir_opt_algebraic.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 21b9acecbe..ba788f221a 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -282,6 +282,8 @@ optimizations = [
    (('iand', ('uge(is_used_once)', a, b), ('uge', a, c)), ('uge', a, ('umax', b, c))),
    (('iand', ('uge(is_used_once)', a, c), ('uge', b, c)), ('uge', ('umin', a, b), c)),
 
+   (('iand', ('ieq', 'a at 32', 0), ('ieq', 'b at 32', 0)), ('ieq', ('ior', 'a at 32', 'b at 32'), 0)),
+
    # These patterns can result when (a < b || a < c) => (a < min(b, c))
    # transformations occur before constant propagation and loop-unrolling.
    (('~flt', a, ('fmax', b, a)), ('flt', a, b)),




More information about the mesa-commit mailing list