From: Jason Ekstrand Date: Fri, 16 Mar 2018 16:52:04 +0000 (-0700) Subject: nir: Return a cursor from nir_instr_remove X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a1452a94fca458c1129f527b775e1124a449ed2b;p=mesa.git nir: Return a cursor from nir_instr_remove Because nir_instr_remove is an inline wrapper around nir_instr_remove_v, the compiler should be able to tell that the return value is unused and not emit the extra code in most cases. Reviewed-by: Kenneth Graunke --- diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 3fb16e6ca5f..8364197480b 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1159,7 +1159,7 @@ remove_defs_uses(nir_instr *instr) nir_foreach_src(instr, remove_use_cb, instr); } -void nir_instr_remove(nir_instr *instr) +void nir_instr_remove_v(nir_instr *instr) { remove_defs_uses(instr); exec_node_remove(&instr->node); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 5ba6a1f0687..cc7c401b40e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2274,7 +2274,21 @@ nir_instr_insert_after_cf_list(struct exec_list *list, nir_instr *after) nir_instr_insert(nir_after_cf_list(list), after); } -void nir_instr_remove(nir_instr *instr); +void nir_instr_remove_v(nir_instr *instr); + +static inline nir_cursor +nir_instr_remove(nir_instr *instr) +{ + nir_cursor cursor; + nir_instr *prev = nir_instr_prev(instr); + if (prev) { + cursor = nir_after_instr(prev); + } else { + cursor = nir_before_block(instr->block); + } + nir_instr_remove_v(instr); + return cursor; +} /** @} */ diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c index 89ddc8dd406..cc8f00f9d37 100644 --- a/src/compiler/nir/nir_opt_copy_prop_vars.c +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c @@ -349,21 +349,6 @@ store_to_entry(struct copy_prop_var_state *state, struct copy_entry *entry, } } -/* Remove an instruction and return a cursor pointing to where it was */ -static nir_cursor -instr_remove_cursor(nir_instr *instr) -{ - nir_cursor cursor; - nir_instr *prev = nir_instr_prev(instr); - if (prev) { - cursor = nir_after_instr(prev); - } else { - cursor = nir_before_block(instr->block); - } - nir_instr_remove(instr); - return cursor; -} - /* Do a "load" from an SSA-based entry return it in "value" as a value with a * single SSA def. Because an entry could reference up to 4 different SSA * defs, a vecN operation may be inserted to combine them into a single SSA @@ -396,7 +381,7 @@ load_from_ssa_entry_value(struct copy_prop_var_state *state, if (all_same) { /* Our work here is done */ - b->cursor = instr_remove_cursor(&intrin->instr); + b->cursor = nir_instr_remove(&intrin->instr); intrin->instr.block = NULL; return true; } @@ -594,7 +579,7 @@ load_from_deref_entry_value(struct copy_prop_var_state *state, value_tail->child = nir_deref_clone(src_tail->child, value_tail); } - b->cursor = instr_remove_cursor(&intrin->instr); + b->cursor = nir_instr_remove(&intrin->instr); return true; }