Mesa (master): nir/algebraic: Generalize an optimization

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Dec 16 21:03:24 UTC 2018


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Thu Dec  6 12:56:33 2018 -0600

nir/algebraic: Generalize an optimization

This just makes it nicely scale across bit sizes.

Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Tested-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 1f1dd9e8b7..72445ee830 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -27,6 +27,7 @@ from __future__ import print_function
 
 from collections import OrderedDict
 import nir_algebraic
+from nir_opcodes import type_sizes
 import itertools
 
 # Convenience variables
@@ -755,9 +756,15 @@ for left, right in itertools.combinations_with_replacement(invert.keys(), 2):
    optimizations.append((('inot', ('iand(is_used_once)', (left, a, b), (right, c, d))),
                          ('ior', (invert[left], a, b), (invert[right], c, d))))
 
+# Optimize x2bN(b2x(x)) -> x
+for size in type_sizes('bool'):
+    aN = 'a@' + str(size)
+    f2bN = 'f2b' + str(size)
+    i2bN = 'i2b' + str(size)
+    optimizations.append(((f2bN, ('b2f', aN)), a))
+    optimizations.append(((i2bN, ('b2i', aN)), a))
+
 # Optimize x2yN(b2x(x)) -> b2y
-optimizations.append((('f2b32', ('b2f', 'a at 32')), a))
-optimizations.append((('i2b32', ('b2i', 'a at 32')), a))
 for x, y in itertools.product(['f', 'u', 'i'], ['f', 'u', 'i']):
    if x != 'f' and y != 'f' and x != y:
       continue




More information about the mesa-commit mailing list