[Mesa-dev] [PATCH 02/38] nir: Return a cursor from nir_instr_remove
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 21 05:54:36 UTC 2018
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.
---
src/compiler/nir/nir.c | 2 +-
src/compiler/nir/nir.h | 16 +++++++++++++++-
src/compiler/nir/nir_opt_copy_prop_vars.c | 19 ++-----------------
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index a97b119..b16d6fa 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1158,7 +1158,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 8f4a28c..cc0b171 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2277,7 +2277,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 89ddc8d..cc8f00f 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;
}
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list