[Mesa-dev] [PATCH 10/13] nir: verify destination bit size when checking algebraic optimizations

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Apr 12 08:05:19 UTC 2016


Some instructions (like flrp in i965) cannot be lowered depending on the
bit size because it doesn't support all bit sizes.

If the bit size field is defined in nir_opt_algebraic.py, take it into
account.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/nir/nir_algebraic.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 53a7907..f3630e0 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -180,6 +180,11 @@ class SearchAndReplace(object):
       else:
          self.condition = 'true'
 
+      if len(transform) > 3:
+         self.bit_size = transform[3]
+      else:
+         self.bit_size = 0
+
       if self.condition not in condition_list:
          condition_list.append(self.condition)
       self.condition_index = condition_list.index(self.condition)
@@ -208,6 +213,7 @@ struct transform {
    const nir_search_expression *search;
    const nir_search_value *replace;
    unsigned condition_offset;
+   unsigned bit_size;
 };
 
 struct opt_state {
@@ -226,7 +232,7 @@ struct opt_state {
 
 static const struct transform ${pass_name}_${opcode}_xforms[] = {
 % for xform in xform_list:
-   { &${xform.search.name}, ${xform.replace.c_ptr}, ${xform.condition_index} },
+   { &${xform.search.name}, ${xform.replace.c_ptr}, ${xform.condition_index}, ${xform.bit_size}},
 % endfor
 };
 % endfor
@@ -249,6 +255,9 @@ ${pass_name}_block(nir_block *block, void *void_state)
       case nir_op_${opcode}:
          for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
             const struct transform *xform = &${pass_name}_${opcode}_xforms[i];
+            if (xform->bit_size != 0 &&
+                alu->dest.dest.ssa.bit_size != xform->bit_size)
+               continue;
             if (state->condition_flags[xform->condition_offset] &&
                 nir_replace_instr(alu, xform->search, xform->replace,
                                   state->mem_ctx)) {
-- 
2.5.0



More information about the mesa-dev mailing list