Mesa (master): vc4: Split two notions of instructions having side effects.
Eric Anholt
anholt at kemper.freedesktop.org
Sat Jan 10 20:01:33 UTC 2015
Module: Mesa
Branch: master
Commit: c772c92153fdcd4ba4920b7ef1745ce83b09603b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c772c92153fdcd4ba4920b7ef1745ce83b09603b
Author: Eric Anholt <eric at anholt.net>
Date: Sat Jan 10 14:57:16 2015 +1300
vc4: Split two notions of instructions having side effects.
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 | 3 ++-
src/gallium/drivers/vc4/vc4_opt_dead_code.c | 3 ++-
src/gallium/drivers/vc4/vc4_opt_vpm_writes.c | 4 +++-
src/gallium/drivers/vc4/vc4_qir.c | 8 +++++++-
src/gallium/drivers/vc4/vc4_qir.h | 1 +
5 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/vc4/vc4_opt_cse.c b/src/gallium/drivers/vc4/vc4_opt_cse.c
index 2ca736f..aff777b 100644
--- a/src/gallium/drivers/vc4/vc4_opt_cse.c
+++ b/src/gallium/drivers/vc4/vc4_opt_cse.c
@@ -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;
diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c b/src/gallium/drivers/vc4/vc4_opt_dead_code.c
index 408bd43..f555fcb 100644
--- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c
+++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c
@@ -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--;
diff --git a/src/gallium/drivers/vc4/vc4_opt_vpm_writes.c b/src/gallium/drivers/vc4/vc4_opt_vpm_writes.c
index 477d326..0269e32 100644
--- a/src/gallium/drivers/vc4/vc4_opt_vpm_writes.c
+++ b/src/gallium/drivers/vc4/vc4_opt_vpm_writes.c
@@ -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
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c
index 4f73932..40356c9 100644
--- a/src/gallium/drivers/vc4/vc4_qir.c
+++ b/src/gallium/drivers/vc4/vc4_qir.c
@@ -141,6 +141,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
* point/line coordinates reads, because they're generated by
@@ -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
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index 0c2bca9..ebec7cc 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -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);
More information about the mesa-commit
mailing list