[Mesa-dev] [PATCH] nir: Add a couple of iand/ior optimizations

Jason Ekstrand jason at jlekstrand.net
Mon Jul 23 07:36:15 UTC 2018


Spotted in a shader in Batman: Arkham City.
---
 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 ba277fdfd0e..f2007852b21 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -377,6 +377,8 @@ optimizations = [
    (('ixor', a, a), 0),
    (('ixor', a, 0), a),
    (('inot', ('inot', a)), a),
+   (('ior', ('iand', a, b), b), b),
+   (('iand', ('ior', a, b), b), b),
    # DeMorgan's Laws
    (('iand', ('inot', a), ('inot', b)), ('inot', ('ior',  a, b))),
    (('ior',  ('inot', a), ('inot', b)), ('inot', ('iand', a, b))),
-- 
2.17.1



More information about the mesa-dev mailing list