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;
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--;
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
*/
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
if (inst->dst.file == QFILE_VPM)
return true;
- return qir_op_info[inst->op].has_side_effects;
+ return false;
}
bool
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);