diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-04-30 14:17:06 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-19 20:21:28 +0000 |
commit | db7b0eb9112479a82a775c879186602e15c733ab (patch) | |
tree | 8b1a92882990692389fdbcf7afb6bf04f96c0c32 /src/panfrost/midgard | |
parent | 5500b1f2801cf7b0056cdbdec4d168bda58e36e0 (diff) |
pan/mdg: Use helpers for branch/discard inversion
Doesn't come up on glmark but would covered by the old passes.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5102>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index d2575e5daca..9cede6f96de 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1350,6 +1350,19 @@ search_var(struct exec_list *vars, unsigned driver_loc) return NULL; } +static unsigned +mir_get_branch_cond(nir_src *src, bool *invert) +{ + /* Wrap it. No swizzle since it's a scalar */ + + nir_alu_src alu = { + .src = *src + }; + + *invert = pan_has_source_mod(&alu, nir_op_inot); + return nir_src_index(NULL, &alu.src); +} + static void emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) { @@ -1363,7 +1376,8 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) discard.branch.target_type = TARGET_DISCARD; if (conditional) { - discard.src[0] = nir_src_index(ctx, &instr->src[0]); + discard.src[0] = mir_get_branch_cond(&instr->src[0], + &discard.branch.invert_conditional); discard.src_types[0] = nir_type_uint32; } @@ -2230,10 +2244,12 @@ emit_if(struct compiler_context *ctx, nir_if *nif) midgard_block *before_block = ctx->current_block; /* Speculatively emit the branch, but we can't fill it in until later */ + bool inv = false; EMIT(branch, true, true); midgard_instruction *then_branch = mir_last_in_block(ctx->current_block); - then_branch->src[0] = nir_src_index(ctx, &nif->condition); + then_branch->src[0] = mir_get_branch_cond(&nif->condition, &inv); then_branch->src_types[0] = nir_type_uint32; + then_branch->branch.invert_conditional = !inv; /* Emit the two subblocks. */ midgard_block *then_block = emit_cf_list(ctx, &nif->then_list); |