<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 7, 2019 at 9:28 AM Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Divergence is generally when multiple parallel "lanes" go in different<br>
directions -- a jump that some lanes take and others don't, which<br>
requires the GPU to execute some lanes first, and then the rest,<br>
separately.<br>
<br>
IMO better names might be is_scalar_swizzle or something.<br></blockquote><div><br></div><div>I was going to make roughly the same comment but couldn't come up with a good name suggestion. I like is_scalar_swizzle. :-D<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On Mon, May 6, 2019 at 11:00 PM Alyssa Rosenzweig <<a href="mailto:alyssa@rosenzweig.io" target="_blank">alyssa@rosenzweig.io</a>> wrote:<br>
><br>
> This allows algebraic optimizations to check if the argument accesses<br>
> multiple distinct components of a vector. So a swizzle like "xyz" will<br>
> return true, but "yyy" will return false, as will a scalar. This can be<br>
> useful for optimizations on vector processors, where a convergent<br>
> swizzle can be done in one clock (replicating as if a scalar) but a<br>
> divergent one must be scalarized. In these cases, it is useful to<br>
> optimize differently based on whether the swizzle diverges. (Use case is<br>
> the "csel" condition on Midgard).<br>
><br>
> Signed-off-by: Alyssa Rosenzweig <<a href="mailto:alyssa@rosenzweig.io" target="_blank">alyssa@rosenzweig.io</a>><br>
> Cc: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
> ---<br>
> src/compiler/nir/nir_search_helpers.h | 16 ++++++++++++++++<br>
> 1 file changed, 16 insertions(+)<br>
><br>
> diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h<br>
> index 1624508993d..46d7c300643 100644<br>
> --- a/src/compiler/nir/nir_search_helpers.h<br>
> +++ b/src/compiler/nir/nir_search_helpers.h<br>
> @@ -143,6 +143,22 @@ is_not_const(nir_alu_instr *instr, unsigned src, UNUSED unsigned num_components,<br>
> return !nir_src_is_const(instr->src[src].src);<br>
> }<br>
><br>
> +/* I.e. a vector that actually accesses multiple channels */<br>
> +<br>
> +static inline bool<br>
> +is_divergent_vector(nir_alu_instr *instr, UNUSED unsigned src, unsigned num_components,<br>
> + const uint8_t *swizzle)<br>
> +{<br>
> + unsigned first_component = swizzle[0];<br>
> +<br>
> + for (unsigned i = 1; i < num_components; ++i) {<br>
> + if (swizzle[i] != first_component)<br>
> + return true;<br>
> + }<br>
<br>
Can num_components be 1? If so, then this will return false, whereas<br>
you probably wanted it to return true.<br></blockquote><div><br></div><div>Yes, it can. Good catch!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +<br>
> + return false;<br>
> +}<br>
> +<br>
> static inline bool<br>
> is_used_more_than_once(nir_alu_instr *instr)<br>
> {<br>
> --<br>
> 2.20.1<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div></div>