<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Oct 20, 2018 at 12:55 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 src/compiler/nir/nir_search.c | 70 +++++++----------------------------<br>
 1 file changed, 13 insertions(+), 57 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c<br>
index 21fcbe7aaec..559cc893583 100644<br>
--- a/src/compiler/nir/nir_search.c<br>
+++ b/src/compiler/nir/nir_search.c<br>
@@ -181,33 +181,14 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,<br>
    case nir_search_value_constant: {<br>
       nir_search_constant *const_val = nir_search_value_as_constant(value);<br>
<br>
-      if (!instr->src[src].src.is_ssa)<br>
+      if (!nir_src_is_const(instr->src[src].src))<br>
          return false;<br>
<br>
-      if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const)<br>
-         return false;<br>
-<br>
-      nir_load_const_instr *load =<br>
-         nir_instr_as_load_const(instr->src[src].src.ssa->parent_instr);<br>
-<br>
       switch (const_val->type) {<br>
       case nir_type_float:<br>
          for (unsigned i = 0; i < num_components; ++i) {<br>
-            double val;<br>
-            switch (load->def.bit_size) {<br>
-            case 16:<br>
-               val = _mesa_half_to_float(load->value.u16[new_swizzle[i]]);<br>
-               break;<br>
-            case 32:<br>
-               val = load->value.f32[new_swizzle[i]];<br>
-               break;<br>
-            case 64:<br>
-               val = load->value.f64[new_swizzle[i]];<br>
-               break;<br>
-            default:<br>
-               unreachable("unknown bit size");<br>
-            }<br>
-<br>
+            double val = nir_src_comp_as_float(instr->src[src].src,<br>
+                                               new_swizzle[i]);<br>
             if (val != const_val->data.d)<br>
                return false;<br>
          }<br>
@@ -215,42 +196,17 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,<br>
<br>
       case nir_type_int:<br>
       case nir_type_uint:<br>
-      case nir_type_bool32:<br>
-         switch (load->def.bit_size) {<br>
-         case 8:<br>
-            for (unsigned i = 0; i < num_components; ++i) {<br>
-               if (load->value.u8[new_swizzle[i]] !=<br>
-                   (uint8_t)const_val->data.u)<br>
-                  return false;<br>
-            }<br>
-            return true;<br>
-<br>
-         case 16:<br>
-            for (unsigned i = 0; i < num_components; ++i) {<br>
-               if (load->value.u16[new_swizzle[i]] !=<br>
-                   (uint16_t)const_val->data.u)<br>
-                  return false;<br>
-            }<br>
-            return true;<br>
-<br>
-         case 32:<br>
-            for (unsigned i = 0; i < num_components; ++i) {<br>
-               if (load->value.u32[new_swizzle[i]] !=<br>
-                   (uint32_t)const_val->data.u)<br>
-                  return false;<br>
-            }<br>
-            return true;<br>
-<br>
-         case 64:<br>
-            for (unsigned i = 0; i < num_components; ++i) {<br>
-               if (load->value.u64[new_swizzle[i]] != const_val->data.u)<br>
-                  return false;<br>
-            }<br>
-            return true;<br>
-<br>
-         default:<br>
-            unreachable("unknown bit size");<br>
+      case nir_type_bool32: {<br>
+         unsigned bit_size = nir_src_bit_size(instr->src[src].src);<br>
+         uint64_t mask = bit_size == 64 ? UINT64_MAX : (1ull << bit_size) - 1;<br>
+         for (unsigned i = 0; i < num_components; ++i) {<br>
+            uint64_t val = nir_src_comp_as_float(instr->src[src].src,<br>
+                                                 new_swizzle[i]);<br></blockquote><div><br></div><div>This should be as_uint.  Fixed locally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+            if ((val & mask) != (const_val->data.u & mask))<br>
+               return false;<br>
          }<br>
+         return true;<br>
+      }<br>
<br>
       default:<br>
          unreachable("Invalid alu source type");<br>
-- <br>
2.19.1<br>
<br>
</blockquote></div></div>