Mesa (master): nir/search: Respect the bit_size parameter on nir_search_value

Jason Ekstrand jekstrand at kemper.freedesktop.org
Wed Apr 27 18:21:11 UTC 2016


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Apr 25 12:41:44 2016 -0700

nir/search: Respect the bit_size parameter on nir_search_value

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/compiler/nir/nir_opt_algebraic.py |  5 ++++-
 src/compiler/nir/nir_search.c         | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index fa7d7c7..fc439f0 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -56,7 +56,10 @@ d = 'd'
 #
 # All expression types can have a bit-size specified.  For opcodes, this
 # looks like "op at 32", for variables it is "a at 32" or "a at uint32" to specify a
-# type and size, and for literals, you can write "2.0 at 32".
+# type and size, and for literals, you can write "2.0 at 32".  In the search half
+# of the expression this indicates that it should only match that particular
+# bit-size.  In the replace half of the expression this indicates that the
+# constructed value should have that bit-size.
 
 optimizations = [
    (('fneg', ('fneg', a)), a),
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index df80c0f..2c2fd92 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -88,6 +88,11 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
    for (unsigned i = 0; i < num_components; ++i)
       new_swizzle[i] = instr->src[src].swizzle[swizzle[i]];
 
+   /* If the value has a specific bit size and it doesn't match, bail */
+   if (value->bit_size &&
+       nir_src_bit_size(instr->src[src].src) != value->bit_size)
+      return false;
+
    switch (value->type) {
    case nir_search_value_expression:
       if (!instr->src[src].src.is_ssa)
@@ -243,6 +248,10 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
 
    assert(instr->dest.dest.is_ssa);
 
+   if (expr->value.bit_size &&
+       instr->dest.dest.ssa.bit_size != expr->value.bit_size)
+      return false;
+
    state->inexact_match = expr->inexact || state->inexact_match;
    state->has_exact_alu = instr->exact || state->has_exact_alu;
    if (state->inexact_match && state->has_exact_alu)
@@ -353,6 +362,11 @@ build_bitsize_tree(void *mem_ctx, struct match_state *state,
    }
    }
 
+   if (value->bit_size) {
+      assert(!tree->is_dest_sized || tree->dest_size == value->bit_size);
+      tree->common_size = value->bit_size;
+   }
+
    return tree;
 }
 




More information about the mesa-commit mailing list