<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 14, 2016 at 10:49 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Both loads and atomics had identical code to rewrite destinations,<br>
and all cases had the same two lines to replace instructions.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/compiler/nir/nir_lower_io.c | 44 ++++++++++++++++++-----------------------<br>
1 file changed, 19 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c<br>
index 45cc671..3a8587a 100644<br>
--- a/src/compiler/nir/nir_lower_io.c<br>
+++ b/src/compiler/nir/nir_lower_io.c<br>
@@ -289,6 +289,8 @@ nir_lower_io_block(nir_block *block,<br>
per_vertex ? &vertex_index : NULL,<br>
state->type_size);<br>
<br>
+ nir_intrinsic_instr *replacement;<br>
+<br>
switch (intrin->intrinsic) {<br>
case nir_intrinsic_load_var: {<br>
nir_intrinsic_instr *load =<br>
@@ -311,18 +313,7 @@ nir_lower_io_block(nir_block *block,<br>
<br>
load->src[per_vertex ? 1 : 0] = nir_src_for_ssa(offset);<br>
<br>
- if (intrin->dest.is_ssa) {<br>
- nir_ssa_dest_init(&load->instr, &load->dest,<br>
- intrin->num_components,<br>
- intrin->dest.ssa.bit_size, NULL);<br>
- nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
- nir_src_for_ssa(&load->dest.ssa));<br>
- } else {<br>
- nir_dest_copy(&load->dest, &intrin->dest, state->mem_ctx);<br>
- }<br>
-<br>
- nir_instr_insert_before(&intrin->instr, &load->instr);<br>
- nir_instr_remove(&intrin->instr);<br>
+ replacement = load;<br>
break;<br>
}<br>
<br>
@@ -348,8 +339,7 @@ nir_lower_io_block(nir_block *block,<br>
<br>
store->src[per_vertex ? 2 : 1] = nir_src_for_ssa(offset);<br>
<br>
- nir_instr_insert_before(&intrin->instr, &store->instr);<br>
- nir_instr_remove(&intrin->instr);<br>
+ replacement = store;<br>
break;<br>
}<br>
<br>
@@ -379,24 +369,28 @@ nir_lower_io_block(nir_block *block,<br>
nir_src_copy(&atomic->src[i+1], &intrin->src[i], atomic);<br>
}<br>
<br>
+ replacement = atomic;<br>
+ break;<br>
+ }<br>
+<br>
+ default:<br>
+ break;<br>
+ }<br>
+<br>
+ if (nir_intrinsic_infos[intrin->intrinsic].has_dest) {<br>
if (intrin->dest.is_ssa) {<br>
- nir_ssa_dest_init(&atomic->instr, &atomic->dest,<br>
- intrin->dest.ssa.num_components,<br>
+ nir_ssa_dest_init(&replacement->instr, &replacement->dest,<br>
+ intrin->num_components,<br></blockquote><div><br></div><div>I think I'd rather keep it as intrin->dest.ssa.num_components. That seems more reliable and more consistent with bit_size.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
intrin->dest.ssa.bit_size, NULL);<br>
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
- nir_src_for_ssa(&atomic->dest.ssa));<br>
+ nir_src_for_ssa(&replacement->dest.ssa));<br>
} else {<br>
- nir_dest_copy(&atomic->dest, &intrin->dest, state->mem_ctx);<br>
+ nir_dest_copy(&replacement->dest, &intrin->dest, state->mem_ctx);<br>
}<br>
-<br>
- nir_instr_insert_before(&intrin->instr, &atomic->instr);<br>
- nir_instr_remove(&intrin->instr);<br>
- break;<br>
}<br>
<br>
- default:<br>
- break;<br>
- }<br>
+ nir_instr_insert_before(&intrin->instr, &replacement->instr);<br>
+ nir_instr_remove(&intrin->instr);<br>
}<br>
<br>
return true;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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>
</font></span></blockquote></div><br></div></div>