diff options
author | Eric Anholt <[email protected]> | 2014-10-09 14:45:14 +0200 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-10-09 21:47:06 +0200 |
commit | b73cab6826b54cdfa138aefb476f1f0d42b87b6a (patch) | |
tree | ca57dfe309aa333bb5517b63e702948de244c727 /src/gallium/drivers | |
parent | 93cac2637ba5a7cd5c79a0e74b87298fae807135 (diff) |
vc4: Dead code eliminate unused SF instructions.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_dead_code.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c b/src/gallium/drivers/vc4/vc4_opt_dead_code.c index 9f7606fb52b..0c273fff8f5 100644 --- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c +++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c @@ -33,12 +33,25 @@ #include "vc4_qir.h" +static bool debug; + +static void +dce(struct vc4_compile *c, struct qinst *inst) +{ + if (debug) { + fprintf(stderr, "Removing: "); + qir_dump_inst(c, inst); + fprintf(stderr, "\n"); + } + qir_remove_instruction(inst); +} + bool qir_opt_dead_code(struct vc4_compile *c) { bool progress = false; - bool debug = false; bool *used = calloc(c->num_temps, sizeof(bool)); + bool sf_used = false; struct simple_node *node, *t; for (node = c->instructions.prev, t = node->prev; @@ -49,16 +62,22 @@ qir_opt_dead_code(struct vc4_compile *c) if (inst->dst.file == QFILE_TEMP && !used[inst->dst.index] && !qir_has_side_effects(inst)) { - if (debug) { - fprintf(stderr, "Removing: "); - qir_dump_inst(c, inst); - fprintf(stderr, "\n"); - } - qir_remove_instruction(inst); + dce(c, inst); progress = true; continue; } + if (qir_depends_on_flags(inst)) + sf_used = true; + if (inst->op == QOP_SF) { + if (!sf_used) { + dce(c, inst); + progress = true; + continue; + } + sf_used = false; + } + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { if (inst->src[i].file == QFILE_TEMP) used[inst->src[i].index] = true; |