{
worklist_elem *elem = ralloc(worklist, worklist_elem);
elem->instr = instr;
- instr->live = true;
+ instr->pass_flags = 1;
exec_list_push_tail(worklist, &elem->node);
}
{
struct exec_list *worklist = (struct exec_list *) _state;
- if (src->is_ssa && !src->ssa->parent_instr->live) {
+ if (src->is_ssa && !src->ssa->parent_instr->pass_flags) {
worklist_push(worklist, src->ssa->parent_instr);
}
nir_alu_instr *alu_instr;
nir_intrinsic_instr *intrin_instr;
nir_tex_instr *tex_instr;
- nir_load_const_instr *load_const_instr;
- instr->live = false;
+ /* We use the pass_flags to store the live/dead information. In DCE, we
+ * just treat it as a zero/non-zerl boolean for whether or not the
+ * instruction is live.
+ */
+ instr->pass_flags = 0;
switch (instr->type) {
case nir_instr_type_call:
worklist_push(worklist, instr);
break;
- case nir_instr_type_load_const:
- load_const_instr = nir_instr_as_load_const(instr);
- if (!load_const_instr->dest.is_ssa)
- worklist_push(worklist, instr);
- break;
-
default:
break;
}
nir_foreach_instr(block, instr)
init_instr(instr, worklist);
- nir_if *following_if = nir_block_following_if(block);
+ nir_if *following_if = nir_block_get_following_if(block);
if (following_if) {
if (following_if->condition.is_ssa &&
- !following_if->condition.ssa->parent_instr->live)
+ !following_if->condition.ssa->parent_instr->pass_flags)
worklist_push(worklist, following_if->condition.ssa->parent_instr);
}
bool *progress = (bool *) _state;
nir_foreach_instr_safe(block, instr) {
- if (!instr->live) {
+ if (!instr->pass_flags) {
nir_instr_remove(instr);
*progress = true;
}