Mesa (master): nir: Recognize imul(b2i(a), b2i(b)) as a logical AND.

Matt Turner mattst88 at kemper.freedesktop.org
Thu May 7 18:03:16 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue May  5 19:50:58 2015 -0700

nir: Recognize imul(b2i(a), b2i(b)) as a logical AND.

Four shaders in Unreal 4's Sun Temple are helped, and gain SIMD16
because we avoid an integer multiplication.

instructions in affected programs:     2353 -> 2245 (-4.59%)
helped:                                4
GAINED:                                4

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Glenn Kennard <glenn.kennard at gmail.com>

---

 src/glsl/nir/nir_opt_algebraic.py |    1 +
 1 file changed, 1 insertion(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 2a2b956..92928cf 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -101,6 +101,7 @@ optimizations = [
    (('seq', a, b), ('b2f', ('feq', a, b)), 'options->lower_scmp'),
    (('sne', a, b), ('b2f', ('fne', a, b)), 'options->lower_scmp'),
    # Emulating booleans
+   (('imul', ('b2i', a), ('b2i', b)), ('b2i', ('iand', a, b))),
    (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
    (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
    (('iand', 'a at bool', 1.0), ('b2f', a)),




More information about the mesa-commit mailing list