aboutsummaryrefslogtreecommitdiffstats
path: root/src/broadcom
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-12-31 13:09:45 -0800
committerEric Anholt <[email protected]>2019-01-02 14:12:29 -0800
commit078dc176bcc2cc36c609d04affe073c3225bf4bf (patch)
tree9e47e5993bd1039ffcb06640e79076c2f7e568d9 /src/broadcom
parent2e0433b6874bc558305b557349221de4a2fcf243 (diff)
v3d: Don't try to fold non-SSA-src comparisons into bcsels.
There could have been a write of a src in between the comparison and the bcsel that would invalidate the comparison.
Diffstat (limited to 'src/broadcom')
-rw-r--r--src/broadcom/compiler/nir_to_vir.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index ac3e1033536..e2cbae4174b 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -559,12 +559,28 @@ ntq_emit_comparison(struct v3d_compile *c,
return true;
}
+/* Finds an ALU instruction that generates our src value that could
+ * (potentially) be greedily emitted in the consuming instruction.
+ */
static struct nir_alu_instr *
ntq_get_alu_parent(nir_src src)
{
if (!src.is_ssa || src.ssa->parent_instr->type != nir_instr_type_alu)
return NULL;
- return nir_instr_as_alu(src.ssa->parent_instr);
+ nir_alu_instr *instr = nir_instr_as_alu(src.ssa->parent_instr);
+ if (!instr)
+ return NULL;
+
+ /* If the ALU instr's srcs are non-SSA, then we would have to avoid
+ * moving emission of the ALU instr down past another write of the
+ * src.
+ */
+ for (int i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
+ if (!instr->src[i].src.is_ssa)
+ return NULL;
+ }
+
+ return instr;
}
/**