<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 6, 2018 at 2:23 PM, Caio Marcelo de Oliveira Filho <span dir="ltr"><<a href="mailto:caio.oliveira@intel.com" target="_blank">caio.oliveira@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
> +static void<br>
> +emit_load_store_deref(nir_<wbr>builder *b, nir_intrinsic_instr *orig_instr,<br>
> + nir_deref_instr *parent,<br>
> + nir_deref_instr **deref_arr,<br>
> + nir_ssa_def **dest, nir_ssa_def *src)<br>
> +{<br>
> + for (; *deref_arr; deref_arr++) {<br>
> + nir_deref_instr *deref = *deref_arr;<br>
> + if (deref->deref_type == nir_deref_type_array &&<br>
> + nir_src_as_const_value(deref-><wbr>arr.index) == NULL) {<br>
> + int length = glsl_get_length(parent->type);<br>
> +<br>
> + emit_indirect_load_store_<wbr>deref(b, orig_instr, parent, deref_arr,<br>
> + 0, length, dest, src);<br>
<br>
</span>Side note: after reading the existing code (that goes from<br>
-base_offset to length - base_offset, and later adds base_offset), I'm<br>
kind of glad this goes from 0 to length.<br>
<span class=""><br>
<br>
> +static bool<br>
> +lower_indirect_derefs_block(<wbr>nir_block *block, nir_builder *b,<br>
> + nir_variable_mode modes)<br>
> +{<br>
<br>
</span>(...)<br>
<span class=""><br>
> + nir_deref_instr *deref =<br>
> + nir_instr_as_deref(intrin-><wbr>src[0].ssa->parent_instr);<br>
<br>
</span>Maybe use the helper 'nir_src_as_deref(intrin->src[<wbr>0])'?<br>
<span class=""><br>
> +<br>
> + /* Walk the deref chain back to the base and look for indirects */<br>
> + bool has_indirect = false;<br>
> + nir_deref_instr *base = deref;<br>
> + while (base->deref_type != nir_deref_type_var) {<br>
> + if (base->deref_type == nir_deref_type_array &&<br>
> + nir_src_as_const_value(base-><wbr>arr.index) == NULL)<br>
> + has_indirect = true;<br>
> +<br>
> + base = nir_instr_as_deref(base-><wbr>parent.ssa->parent_instr);<br>
<br>
</span>Maybe use the helper 'base = nir_deref_instr_parent(base);'<wbr>?<br></blockquote><div><br></div><div>Yeah, due to rebasing, this patch predates those helpers. Changed locally. <br></div></div></div></div>