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

Author: Jason Ekstrand <[email protected]>
Date:   Tue Jan 10 10:24:55 2017 -0800

nir/search: Only allow matching SSA values

This is more correct and should also be a tiny bit faster since we're
just comparing pointers instead of calling nir_src_equal.

Reviewed-by: Timothy Arceri <[email protected]>
Cc: "13.0" <[email protected]>

---

 src/compiler/nir/nir_search.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index b34b13f..10a0941 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -98,6 +98,16 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
 {
    uint8_t new_swizzle[4];
 
+   /* Searching only works on SSA values because, if it's not SSA, we can't
+    * know if the value changed between one instance of that value in the
+    * expression and another.  Also, the replace operation will place reads of
+    * that value right before the last instruction in the expression we're
+    * replacing so those reads will happen after the original reads and may
+    * not be valid if they're register reads.
+    */
+   if (!instr->src[src].src.is_ssa)
+      return false;
+
    /* If the source is an explicitly sized source, then we need to reset
     * both the number of components and the swizzle.
     */
@@ -116,9 +126,6 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
 
    switch (value->type) {
    case nir_search_value_expression:
-      if (!instr->src[src].src.is_ssa)
-         return false;
-
       if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu)
          return false;
 
@@ -131,8 +138,7 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
       assert(var->variable < NIR_SEARCH_MAX_VARIABLES);
 
       if (state->variables_seen & (1 << var->variable)) {
-         if (!nir_srcs_equal(state->variables[var->variable].src,
-                             instr->src[src].src))
+         if (state->variables[var->variable].src.ssa != 
instr->src[src].src.ssa)
             return false;
 
          assert(!instr->src[src].abs && !instr->src[src].negate);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to