summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_qir.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-08-25 00:12:21 -0700
committerEric Anholt <[email protected]>2014-09-04 11:39:51 -0700
commit55d2a1626219ac041ce05477827b592efa1c7b81 (patch)
tree8cd77b31a7e725ff3fd34933dfd481246d5955ad /src/gallium/drivers/vc4/vc4_qir.c
parent80b27ca2cd8cd2bb2937baa441c43a396887cc03 (diff)
vc4: Add a CSE optimization pass.
Debugging a regression in discard support was just too full of duplicate instructions, so I decided to remove them instead of re-analyzing each of them as I dumped their outputs in simulation.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_qir.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c
index 93f97c219f7..a017a72c14b 100644
--- a/src/gallium/drivers/vc4/vc4_qir.c
+++ b/src/gallium/drivers/vc4/vc4_qir.c
@@ -127,6 +127,54 @@ qir_has_side_effects(struct qinst *inst)
return qir_op_info[inst->op].has_side_effects;
}
+bool
+qir_depends_on_flags(struct qinst *inst)
+{
+ switch (inst->op) {
+ case QOP_SEL_X_0_NS:
+ case QOP_SEL_X_0_NC:
+ case QOP_SEL_X_0_ZS:
+ case QOP_SEL_X_0_ZC:
+ case QOP_SEL_X_Y_NS:
+ case QOP_SEL_X_Y_NC:
+ case QOP_SEL_X_Y_ZS:
+ case QOP_SEL_X_Y_ZC:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+qir_writes_r4(struct qinst *inst)
+{
+ switch (inst->op) {
+ case QOP_TEX_RESULT:
+ case QOP_TLB_COLOR_READ:
+ case QOP_RCP:
+ case QOP_RSQ:
+ case QOP_EXP2:
+ case QOP_LOG2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+qir_reads_r4(struct qinst *inst)
+{
+ switch (inst->op) {
+ case QOP_R4_UNPACK_A:
+ case QOP_R4_UNPACK_B:
+ case QOP_R4_UNPACK_C:
+ case QOP_R4_UNPACK_D:
+ return true;
+ default:
+ return false;
+ }
+}
+
static void
qir_print_reg(struct qreg reg)
{
@@ -274,6 +322,7 @@ qir_optimize(struct qcompile *c)
bool progress = false;
OPTPASS(qir_opt_algebraic);
+ OPTPASS(qir_opt_cse);
OPTPASS(qir_opt_copy_propagation);
OPTPASS(qir_opt_dead_code);