[Mesa-dev] [PATCH 04/15] nir/algebraic: Set variable classes to the explicit bit size

Jason Ekstrand jason at jlekstrand.net
Fri Nov 9 03:45:05 UTC 2018


Previously, we were checking for a matching bit size late when
propagating bit sizes back down the tree by checking if the variable had
an explicit bit size and if it matched the requested bit class.
However, this check wasn't quite as accurate because it didn't handle
the case where an explicitly sized variable was handed an as yet unsized
bit size class.  This commit changes things around so that we initialize
the variable's bit class with the explicit bit size early if we have one
and then trust in the checks in set_var_bit_class to do the late check.
The checks in set_var_bit_class handle this case much more accurately.
---
 src/compiler/nir/nir_algebraic.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 5b2ec82448b..1f20203764e 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -387,7 +387,13 @@ class BitSizeValidator(object):
          return '{0}-bit'.format(bit_class)
 
    def _propagate_bit_size_up(self, val):
-      if isinstance(val, (Constant, Variable)):
+      if isinstance(val, Constant):
+         return val.bit_size
+
+      elif isinstance(val, Variable):
+         # Record this variables bit size (if one is set)
+         if val.bit_size != 0:
+            self._set_var_bit_class(val, val.bit_size)
          return val.bit_size
 
       elif isinstance(val, Expression):
@@ -435,9 +441,6 @@ class BitSizeValidator(object):
                 .format(val.bit_size, bit_class, str(val))
 
       elif isinstance(val, Variable):
-         assert val.bit_size == 0 or val.bit_size == bit_class, \
-                'Variable is {0}-bit but a {1}-bit value is required: {2}' \
-                .format(val.bit_size, bit_class, str(val))
          self._set_var_bit_class(val, bit_class)
 
       elif isinstance(val, Expression):
-- 
2.19.1



More information about the mesa-dev mailing list