<div dir="ltr"><div>6-8 are</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 15, 2018 at 12:45 AM Caio Marcelo de Oliveira Filho <<a href="mailto:caio.oliveira@intel.com">caio.oliveira@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">These are covered by another pass now.<br>
---<br>
src/compiler/nir/nir_opt_copy_prop_vars.c | 84 +++--------------------<br>
1 file changed, 8 insertions(+), 76 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
index 9fecaf0eeec..5276aa176d8 100644<br>
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
@@ -38,10 +38,7 @@<br>
* 1) Copy-propagation on variables that have indirect access. This includes<br>
* propagating from indirect stores into indirect loads.<br>
*<br>
- * 2) Dead code elimination of store_var and copy_var intrinsics based on<br>
- * killed destination values.<br>
- *<br>
- * 3) Removal of redundant load_deref intrinsics. We can't trust regular CSE<br>
+ * 2) Removal of redundant load_deref intrinsics. We can't trust regular CSE<br>
* to do this because it isn't aware of variable writes that may alias the<br>
* value and make the former load invalid.<br>
*<br>
@@ -51,6 +48,8 @@<br>
* rapidly get out of hand. Fortunately, for anything that is only ever<br>
* accessed directly, we get SSA based copy-propagation which is extremely<br>
* powerful so this isn't that great a loss.<br>
+ *<br>
+ * Removal of dead writes to variables is handled by another pass.<br>
*/<br>
<br>
struct value {<br>
@@ -64,9 +63,6 @@ struct value {<br>
struct copy_entry {<br>
struct list_head link;<br>
<br>
- nir_instr *store_instr[4];<br>
-<br>
- unsigned comps_may_be_read;<br>
struct value src;<br>
<br>
nir_deref_instr *dst;<br>
@@ -114,44 +110,6 @@ copy_entry_remove(struct copy_prop_var_state *state, struct copy_entry *entry)<br>
list_add(&entry->link, &state->copy_free_list);<br>
}<br>
<br>
-static void<br>
-remove_dead_writes(struct copy_prop_var_state *state,<br>
- struct copy_entry *entry, unsigned write_mask)<br>
-{<br>
- /* We're overwriting another entry. Some of it's components may not<br>
- * have been read yet and, if that's the case, we may be able to delete<br>
- * some instructions but we have to be careful.<br>
- */<br>
- unsigned dead_comps = write_mask & ~entry->comps_may_be_read;<br>
-<br>
- for (unsigned mask = dead_comps; mask;) {<br>
- unsigned i = u_bit_scan(&mask);<br>
-<br>
- nir_instr *instr = entry->store_instr[i];<br>
-<br>
- /* We may have already deleted it on a previous iteration */<br>
- if (!instr)<br>
- continue;<br>
-<br>
- /* See if this instr is used anywhere that it's not dead */<br>
- bool keep = false;<br>
- for (unsigned j = 0; j < 4; j++) {<br>
- if (entry->store_instr[j] == instr) {<br>
- if (dead_comps & (1 << j)) {<br>
- entry->store_instr[j] = NULL;<br>
- } else {<br>
- keep = true;<br>
- }<br>
- }<br>
- }<br>
-<br>
- if (!keep) {<br>
- nir_instr_remove(instr);<br>
- state->progress = true;<br>
- }<br>
- }<br>
-}<br>
-<br>
static struct copy_entry *<br>
lookup_entry_for_deref(struct copy_prop_var_state *state,<br>
nir_deref_instr *deref,<br>
@@ -165,16 +123,6 @@ lookup_entry_for_deref(struct copy_prop_var_state *state,<br>
return NULL;<br>
}<br>
<br>
-static void<br>
-mark_aliased_entries_as_read(struct copy_prop_var_state *state,<br>
- nir_deref_instr *deref, unsigned components)<br>
-{<br>
- list_for_each_entry(struct copy_entry, iter, &state->copies, link) {<br>
- if (nir_compare_derefs(iter->dst, deref) & nir_derefs_may_alias_bit)<br>
- iter->comps_may_be_read |= components;<br>
- }<br>
-}<br>
-<br>
static struct copy_entry *<br>
get_entry_and_kill_aliases(struct copy_prop_var_state *state,<br>
nir_deref_instr *deref,<br>
@@ -191,11 +139,6 @@ get_entry_and_kill_aliases(struct copy_prop_var_state *state,<br>
}<br>
<br>
nir_deref_compare_result comp = nir_compare_derefs(iter->dst, deref);<br>
- /* This is a store operation. If we completely overwrite some value, we<br>
- * want to delete any dead writes that may be present.<br>
- */<br>
- if (comp & nir_derefs_b_contains_a_bit)<br>
- remove_dead_writes(state, iter, write_mask);<br>
<br>
if (comp & nir_derefs_equal_bit) {<br>
assert(entry == NULL);<br>
@@ -228,25 +171,19 @@ apply_barrier_for_modes(struct copy_prop_var_state *state,<br>
<br>
static void<br>
store_to_entry(struct copy_prop_var_state *state, struct copy_entry *entry,<br>
- const struct value *value, unsigned write_mask,<br>
- nir_instr *store_instr)<br>
+ const struct value *value, unsigned write_mask)<br>
{<br>
- entry->comps_may_be_read &= ~write_mask;<br>
if (value->is_ssa) {<br>
entry->src.is_ssa = true;<br>
/* Only overwrite the written components */<br>
for (unsigned i = 0; i < 4; i++) {<br>
- if (write_mask & (1 << i)) {<br>
- entry->store_instr[i] = store_instr;<br>
+ if (write_mask & (1 << i))<br>
entry->src.ssa[i] = value->ssa[i];<br>
- }<br>
}<br>
} else {<br>
/* Non-ssa stores always write everything */<br>
entry->src.is_ssa = false;<br>
entry->src.deref = value->deref;<br>
- for (unsigned i = 0; i < 4; i++)<br>
- entry->store_instr[i] = store_instr;<br>
}<br>
}<br>
<br>
@@ -490,9 +427,6 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
case nir_intrinsic_load_deref: {<br>
nir_deref_instr *src = nir_src_as_deref(intrin->src[0]);<br>
<br>
- uint8_t comps_read = nir_ssa_def_components_read(&intrin->dest.ssa);<br>
- mark_aliased_entries_as_read(state, src, comps_read);<br>
-<br>
struct copy_entry *src_entry =<br>
lookup_entry_for_deref(state, src, nir_derefs_a_contains_b_bit);<br>
struct value value;<br>
@@ -549,7 +483,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
* subsequent store.<br>
*/<br>
store_to_entry(state, store_entry, &value,<br>
- ((1 << intrin->num_components) - 1), NULL);<br>
+ ((1 << intrin->num_components) - 1));<br>
break;<br>
}<br>
<br>
@@ -565,7 +499,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
unsigned wrmask = nir_intrinsic_write_mask(intrin);<br>
struct copy_entry *entry =<br>
get_entry_and_kill_aliases(state, dst, wrmask);<br>
- store_to_entry(state, entry, &value, wrmask, &intrin->instr);<br>
+ store_to_entry(state, entry, &value, wrmask);<br>
break;<br>
}<br>
<br>
@@ -579,8 +513,6 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
continue;<br>
}<br>
<br>
- mark_aliased_entries_as_read(state, src, 0xf);<br>
-<br>
struct copy_entry *src_entry =<br>
lookup_entry_for_deref(state, src, nir_derefs_a_contains_b_bit);<br>
struct value value;<br>
@@ -610,7 +542,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
<br>
struct copy_entry *dst_entry =<br>
get_entry_and_kill_aliases(state, dst, 0xf);<br>
- store_to_entry(state, dst_entry, &value, 0xf, &intrin->instr);<br>
+ store_to_entry(state, dst_entry, &value, 0xf);<br>
break;<br>
}<br>
<br>
-- <br>
2.19.0<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>
</blockquote></div>