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