*/
static void
-instr_dce(struct ir3_instruction *instr, bool falsedep)
+mark_array_use(struct ir3_instruction *instr, struct ir3_register *reg)
{
- struct ir3_instruction *src;
+ if (reg->flags & IR3_REG_ARRAY) {
+ struct ir3_array *arr =
+ ir3_lookup_array(instr->block->shader, reg->array.id);
+ arr->unused = false;
+ }
+}
+static void
+instr_dce(struct ir3_instruction *instr, bool falsedep)
+{
/* don't mark falsedep's as used, but otherwise process them normally: */
if (!falsedep)
instr->flags &= ~IR3_INSTR_UNUSED;
if (ir3_instr_check_mark(instr))
return;
+ if (writes_gpr(instr))
+ mark_array_use(instr, instr->regs[0]); /* dst */
+
+ foreach_src (reg, instr)
+ mark_array_use(instr, reg); /* src */
+
foreach_ssa_src_n (src, i, instr) {
instr_dce(src, __is_false_dep(instr, i));
}
}
}
- struct ir3_instruction *out;
+ foreach_array (arr, &ir->array_list)
+ arr->unused = true;
+
foreach_output (out, ir)
instr_dce(out, false);
progress |= remove_unused_by_block(block);
}
+ /* remove un-used arrays: */
+ foreach_array_safe (arr, &ir->array_list) {
+ if (arr->unused)
+ list_delinit(&arr->node);
+ }
+
/* fixup wrmask of split instructions to account for adjusted tex
* wrmask's:
*/
}
/* cleanup unused inputs: */
- struct ir3_instruction *in;
foreach_input_n (in, n, ir)
if (in->flags & IR3_INSTR_UNUSED)
ir->inputs[n] = NULL;