vc4: Split two notions of instructions having side effects.
authorEric Anholt <eric@anholt.net>
Sat, 10 Jan 2015 01:57:16 +0000 (14:57 +1300)
committerEric Anholt <eric@anholt.net>
Sat, 10 Jan 2015 02:24:46 +0000 (15:24 +1300)
Some ops can't be DCEd, while some of the ops that are just important due
to the args they have can be.

src/gallium/drivers/vc4/vc4_opt_cse.c
src/gallium/drivers/vc4/vc4_opt_dead_code.c
src/gallium/drivers/vc4/vc4_opt_vpm_writes.c
src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h

index 2ca736fe4d5b7b30e9ec0ded260a192791aad4c9..aff777beb47a101e20520f614475384b44da4235 100644 (file)
@@ -133,7 +133,8 @@ qir_opt_cse(struct vc4_compile *c)
         foreach_s(node, t, &c->instructions) {
                 struct qinst *inst = (struct qinst *)node;
 
-                if (qir_has_side_effects(c, inst)) {
+                if (qir_has_side_effects(c, inst) ||
+                    qir_has_side_effect_reads(c, inst)) {
                         if (inst->op == QOP_TLB_DISCARD_SETUP)
                                 last_sf = NULL;
                         continue;
index 408bd4302b4072e6913bc17a968d656f8191adc8..f555fcb600e8b8ec6571b32289f5307b115e6463 100644 (file)
@@ -64,7 +64,8 @@ qir_opt_dead_code(struct vc4_compile *c)
                 if (inst->dst.file == QFILE_TEMP &&
                     !used[inst->dst.index] &&
                     (!qir_has_side_effects(c, inst) ||
-                     inst->op == QOP_TEX_RESULT)) {
+                     inst->op == QOP_TEX_RESULT) &&
+                    !(qir_has_side_effect_reads(c, inst))) {
                         if (inst->op == QOP_TEX_RESULT) {
                                 dce_tex = true;
                                 c->num_texture_samples--;
index 477d32605a408e7fe3d4637f89c54de2abd3d2e5..0269e32494a961b44066a684017e95276ae4e73e 100644 (file)
@@ -82,8 +82,10 @@ qir_opt_vpm_writes(struct vc4_compile *c)
                 if (qir_depends_on_flags(inst))
                         continue;
 
-                if (qir_has_side_effects(c, inst))
+                if (qir_has_side_effects(c, inst) ||
+                    qir_has_side_effect_reads(c, inst)) {
                         continue;
+                }
 
                 /* A QOP_TEX_RESULT destination is r4, so we can't move
                  * accesses to it past another QOP_TEX_RESULT which would
index 4f73932e233f8d08dd31314a30ed3888ae4423be..40356c99ff317e30100ef8432cf40d6863e51dd8 100644 (file)
@@ -140,6 +140,12 @@ qir_get_op_nsrc(enum qop qop)
  */
 bool
 qir_has_side_effects(struct vc4_compile *c, struct qinst *inst)
+{
+        return qir_op_info[inst->op].has_side_effects;
+}
+
+bool
+qir_has_side_effect_reads(struct vc4_compile *c, struct qinst *inst)
 {
         /* We can dead-code eliminate varyings, because we only tell the VS
          * about the live ones at the end.  But we have to preserve the
@@ -159,7 +165,7 @@ qir_has_side_effects(struct vc4_compile *c, struct qinst *inst)
         if (inst->dst.file == QFILE_VPM)
                 return true;
 
-        return qir_op_info[inst->op].has_side_effects;
+        return false;
 }
 
 bool
index 0c2bca93d8bc0f9ec4a534345fc0f968e51a3d1d..ebec7ccfbe34fb3f5329f4fdd66fd8fe7c4c9188 100644 (file)
@@ -377,6 +377,7 @@ struct qreg qir_get_temp(struct vc4_compile *c);
 int qir_get_op_nsrc(enum qop qop);
 bool qir_reg_equals(struct qreg a, struct qreg b);
 bool qir_has_side_effects(struct vc4_compile *c, struct qinst *inst);
+bool qir_has_side_effect_reads(struct vc4_compile *c, struct qinst *inst);
 bool qir_is_multi_instruction(struct qinst *inst);
 bool qir_depends_on_flags(struct qinst *inst);
 bool qir_writes_r4(struct qinst *inst);