Mesa (master): vc4: Drop destination register when it's unused.
Eric Anholt
anholt at kemper.freedesktop.org
Fri Oct 7 01:30:46 UTC 2016
Module: Mesa
Branch: master
Commit: 7c7bcbbc7dc7b71e1e3bab69fbcbc8fcbe797cbc
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c7bcbbc7dc7b71e1e3bab69fbcbc8fcbe797cbc
Author: Eric Anholt <eric at anholt.net>
Date: Wed Oct 5 09:21:37 2016 -0700
vc4: Drop destination register when it's unused.
This slightly reduces instructions on shader-db, but I think it's just
perturbing register allocation -- the allocator should have always
trivially colored these nodes, before. This commit is just to make QIR
code failing more intelligible when register allocation fails.
---
src/gallium/drivers/vc4/vc4_opt_dead_code.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c b/src/gallium/drivers/vc4/vc4_opt_dead_code.c
index f516d38..1838c39 100644
--- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c
+++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c
@@ -102,9 +102,30 @@ qir_opt_dead_code(struct vc4_compile *c)
continue;
}
+ if (qir_has_side_effects(c, inst))
+ continue;
+
if (inst->sf ||
- qir_has_side_effects(c, inst) ||
has_nonremovable_reads(c, inst)) {
+ /* If we can't remove the instruction, but we
+ * don't need its destination value, just
+ * remove the destination. The register
+ * allocator would trivially color it and it
+ * wouldn't cause any register pressure, but
+ * it's nicer to read the QIR code without
+ * unused destination regs.
+ */
+ if (inst->dst.file == QFILE_TEMP) {
+ if (debug) {
+ fprintf(stderr,
+ "Removing dst from: ");
+ qir_dump_inst(c, inst);
+ fprintf(stderr, "\n");
+ }
+ c->defs[inst->dst.index] = NULL;
+ inst->dst.file = QFILE_NULL;
+ progress = true;
+ }
continue;
}
More information about the mesa-commit
mailing list