diff options
author | Eric Anholt <[email protected]> | 2014-12-10 14:56:46 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-12-17 19:35:13 -0800 |
commit | e473fbe4690b5cbe3769042a4917f22559e2ba8d (patch) | |
tree | d2c2a467d69a4713651b40bf269db9691544baab /src/gallium/drivers/vc4/vc4_qir.c | |
parent | ff266483fb61fd69775daf5c931ca7a56a26f4ac (diff) |
vc4: Add support for turning constant uniforms into small immediates.
Small immediates have the downside of taking over the raddr B field, so
you might have less chance to pack instructions together thanks to raddr B
conflicts. However, it also reduces some register pressure since it lets
you load 2 "uniform" values in one instruction (avoiding a previous load
of the constant value to a register), and increases some pairing for the
same reason.
total uniforms in shared programs: 16231 -> 13374 (-17.60%)
uniforms in affected programs: 10280 -> 7423 (-27.79%)
total instructions in shared programs: 40795 -> 41168 (0.91%)
instructions in affected programs: 25551 -> 25924 (1.46%)
In a previous version of this patch I had a reduction in instruction count
by forcing the other args alongside a SMALL_IMM to be in the A file or
accumulators, but that increases register pressure and had a bug in
handling FRAG_Z. In this patch is I just use raddr conflict resolution,
which is more expensive. I think I'd rather tweak allocation to have some
way to slightly prefer good choices for files in general, rather than risk
failing to register allocate by forcing things into register classes.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_qir.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index d7251abda1c..8cb9826a21d 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -204,16 +204,22 @@ qir_reads_r4(struct qinst *inst) static void qir_print_reg(struct vc4_compile *c, struct qreg reg) { - const char *files[] = { + static const char *files[] = { [QFILE_TEMP] = "t", [QFILE_VARY] = "v", [QFILE_UNIF] = "u", }; - if (reg.file == QFILE_NULL) + if (reg.file == QFILE_NULL) { fprintf(stderr, "null"); - else + } else if (reg.file == QFILE_SMALL_IMM) { + if ((int)reg.index >= -16 && (int)reg.index <= 15) + fprintf(stderr, "%d", reg.index); + else + fprintf(stderr, "%f", uif(reg.index)); + } else { fprintf(stderr, "%s%d", files[reg.file], reg.index); + } if (reg.file == QFILE_UNIF && c->uniform_contents[reg.index] == QUNIFORM_CONSTANT) { @@ -386,6 +392,7 @@ qir_optimize(struct vc4_compile *c) OPTPASS(qir_opt_cse); OPTPASS(qir_opt_copy_propagation); OPTPASS(qir_opt_dead_code); + OPTPASS(qir_opt_small_immediates); if (!progress) break; |