<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 11, 2017 at 10:08 AM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 12/07/2017 08:12 AM, Jason Ekstrand wrote:<br>
> Instead of calling vtn_add_case for the default case and then looping,<br>
> add an is_default variable and do everything inside the loop. This will<br>
> make the next commit easier.<br>
> ---<br>
> src/compiler/spirv/vtn_cfg.c | 17 ++++++++++++++---<br>
> 1 file changed, 14 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c<br>
> index 25140ff..9d1ca84 100644<br>
> --- a/src/compiler/spirv/vtn_cfg.c<br>
> +++ b/src/compiler/spirv/vtn_cfg.c<br>
> @@ -425,9 +425,20 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,<br>
> const uint32_t *branch_end =<br>
> block->branch + (block->branch[0] >> SpvWordCountShift);<br>
><br>
> - vtn_add_case(b, swtch, break_block, block->branch[2], 0, true);<br>
> - for (const uint32_t *w = block->branch + 3; w < branch_end; w += 2)<br>
> - vtn_add_case(b, swtch, break_block, w[1], w[0], false);<br>
> + bool is_default = true;<br>
> + for (const uint32_t *w = block->branch + 2; w < branch_end;) {<br>
> + uint32_t literal = 0;<br>
> + if (!is_default) {<br>
> + literal = *w;<br>
> + w++;<br>
> + }<br>
> +<br>
> + uint32_t block_id = *w;<br>
> + w++;<br>
<br>
</div></div>In other parts of Mesa, this would be<br>
<br>
const uint32_t block_id = *(w++);<br>
<br>
Is that not the preferred style here too? Having looked ahead at the<br>
next patch, I can see why the other dereference of w is not like this.<br><div class="HOEnZb"><div class="h5"></div></div></blockquote><div><br></div><div>Yeah, that's cleaner. I've switched to that and rebased patch 8 on it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> +<br>
> + vtn_add_case(b, swtch, break_block, block_id, literal, is_default);<br>
> + is_default = false;<br>
> + }<br>
><br>
> /* Now, we go through and walk the blocks. While we walk through<br>
> * the blocks, we also gather the much-needed fall-through<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>