From db7b0eb9112479a82a775c879186602e15c733ab Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 30 Apr 2020 14:17:06 -0400 Subject: [PATCH] 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 Part-of: --- src/panfrost/midgard/midgard_compile.c | 20 ++++++++++++++++++-- 1 file 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); -- 2.30.2