vc4: DCE instructions with a NULL destination.
authorEric Anholt <eric@anholt.net>
Fri, 3 Jun 2016 22:06:52 +0000 (15:06 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 4 Jul 2016 23:33:22 +0000 (16:33 -0700)
I'm going to add an optimization for redundant SF update removal, which
will just remove the SF and leave us (in many cases) with an instruction
with a NULL destination and no side effects.  Rather than teaching that
pass whether the whole instruction can be removed, leave that
responsibility to this pass.

src/gallium/drivers/vc4/vc4_opt_dead_code.c

index d3562ee..ad51ed7 100644 (file)
@@ -86,8 +86,9 @@ qir_opt_dead_code(struct vc4_compile *c)
 
         list_for_each_entry_safe_rev(struct qinst, inst, &c->instructions,
                                      link) {
-                if (inst->dst.file == QFILE_TEMP &&
-                    !used[inst->dst.index] &&
+                if ((inst->dst.file == QFILE_NULL ||
+                     (inst->dst.file == QFILE_TEMP &&
+                      !used[inst->dst.index])) &&
                     !inst->sf &&
                     !qir_has_side_effects(c, inst) &&
                     !has_nonremovable_reads(c, inst)) {