summaryrefslogtreecommitdiffstats
path: root/src/broadcom/compiler
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-12-31 13:05:06 -0800
committerEric Anholt <[email protected]>2019-01-02 14:12:29 -0800
commit2e0433b6874bc558305b557349221de4a2fcf243 (patch)
tree4381c5d44d946c59574bce966d36c9f5f61c2a73 /src/broadcom/compiler
parentc3ae0aa264735fc6528d7ca0bf31a72cab1d2dfb (diff)
v3d: Move the "Find the ALU instruction generating our bool" out of bcsel.
This will be reused for if statements.
Diffstat (limited to 'src/broadcom/compiler')
-rw-r--r--src/broadcom/compiler/nir_to_vir.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 02ae6b20e2c..ac3e1033536 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -559,6 +559,14 @@ ntq_emit_comparison(struct v3d_compile *c,
return true;
}
+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);
+}
+
/**
* Attempts to fold a comparison generating a boolean result into the
* condition code for selecting between two values, instead of comparing the
@@ -567,12 +575,7 @@ ntq_emit_comparison(struct v3d_compile *c,
static struct qreg ntq_emit_bcsel(struct v3d_compile *c, nir_alu_instr *instr,
struct qreg *src)
{
- if (!instr->src[0].src.is_ssa)
- goto out;
- if (instr->src[0].src.ssa->parent_instr->type != nir_instr_type_alu)
- goto out;
- nir_alu_instr *compare =
- nir_instr_as_alu(instr->src[0].src.ssa->parent_instr);
+ nir_alu_instr *compare = ntq_get_alu_parent(instr->src[0].src);
if (!compare)
goto out;