diff options
author | Eric Anholt <[email protected]> | 2014-07-04 09:48:23 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-08 18:59:47 -0700 |
commit | d9d1c14430aaeb5b22aa66b269ba288e3df24103 (patch) | |
tree | 6de477f96625c83d4dc364c76af50753160afd19 /src/gallium/drivers/vc4/vc4_qir.c | |
parent | 1d23d55ae97d07b6eb70a3e37a91ecb7de38d8d2 (diff) |
vc4: Add dead code elimination.
This cleans up a bunch of noise in the compiled coordinate shaders (since
we don't need the varying outputs), and also from writemasked instructions
with negated src operands.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_qir.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 308154ff34a..13714115214 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -32,6 +32,7 @@ struct qir_op_info { const char *name; uint8_t ndst, nsrc; + bool has_side_effects; }; static const struct qir_op_info qir_op_info[] = { @@ -57,9 +58,9 @@ static const struct qir_op_info qir_op_info[] = { [QOP_LOG2] = { "log2", 1, 2 }, [QOP_PACK_COLORS] = { "pack_colors", 1, 4 }, [QOP_PACK_SCALED] = { "pack_scaled", 1, 2 }, - [QOP_VPM_WRITE] = { "vpm_write", 0, 1 }, - [QOP_VPM_READ] = { "vpm_read", 0, 1 }, - [QOP_TLB_COLOR_WRITE] = { "tlb_color", 0, 1 }, + [QOP_VPM_WRITE] = { "vpm_write", 0, 1, true }, + [QOP_VPM_READ] = { "vpm_read", 0, 1, true }, + [QOP_TLB_COLOR_WRITE] = { "tlb_color", 0, 1, true }, [QOP_VARY_ADD_C] = { "vary_add_c", 1, 1 }, }; @@ -81,6 +82,18 @@ qir_get_op_nsrc(enum qop qop) abort(); } +bool +qir_has_side_effects(struct qinst *inst) +{ + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { + if (inst->src[i].file == QFILE_VARY || + inst->src[i].file == QFILE_UNIF) + return true; + } + + return qir_op_info[inst->op].has_side_effects; +} + static void qir_print_reg(struct qreg reg) { @@ -228,6 +241,7 @@ qir_optimize(struct qcompile *c) bool progress = false; OPTPASS(qir_opt_algebraic); + OPTPASS(qir_opt_dead_code); if (!progress) break; |