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.
This commit is contained in:
Eric Anholt 2015-01-10 14:57:16 +13:00
parent a58ae83882
commit c772c92153
5 changed files with 15 additions and 4 deletions

View 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;

View 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--;

View 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

View 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

View 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);