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 <kenneth@whitecape.org>
This commit is contained in:
@@ -1159,7 +1159,7 @@ remove_defs_uses(nir_instr *instr)
|
|||||||
nir_foreach_src(instr, remove_use_cb, 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);
|
remove_defs_uses(instr);
|
||||||
exec_node_remove(&instr->node);
|
exec_node_remove(&instr->node);
|
||||||
|
@@ -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);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@@ -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
|
/* 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
|
* 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
|
* 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) {
|
if (all_same) {
|
||||||
/* Our work here is done */
|
/* Our work here is done */
|
||||||
b->cursor = instr_remove_cursor(&intrin->instr);
|
b->cursor = nir_instr_remove(&intrin->instr);
|
||||||
intrin->instr.block = NULL;
|
intrin->instr.block = NULL;
|
||||||
return true;
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user