From 9367d2ca37a3b8108ecb74e2875a600b5543c163 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Thu, 29 Aug 2019 21:14:54 -0700 Subject: nir: allow specifying filter callback in lower_alu_to_scalar Set of opcodes doesn't have enough flexibility in certain cases. E.g. Utgard PP has vector conditional select operation, but condition is always scalar. Lowering all the vector selects to scalar increases instruction number, so we need a way to filter only those ops that can't be handled in hardware. Reviewed-by: Qiang Yu Reviewed-by: Eric Anholt Reviewed-by: Jason Ekstrand Signed-off-by: Vasily Khoruzhick --- src/gallium/drivers/freedreno/a2xx/ir2_nir.c | 35 +++++++++++++++++++--------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/gallium/drivers/freedreno') diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c index 9d36f7092ef..6915194234d 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c +++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c @@ -1062,6 +1062,29 @@ static void cleanup_binning(struct ir2_context *ctx) ir2_optimize_nir(ctx->nir, false); } +static bool +ir2_alu_to_scalar_filter_cb(const nir_instr *instr, const void *data) +{ + if (instr->type != nir_instr_type_alu) + return false; + + nir_alu_instr *alu = nir_instr_as_alu(instr); + switch (alu->op) { + case nir_op_frsq: + case nir_op_frcp: + case nir_op_flog2: + case nir_op_fexp2: + case nir_op_fsqrt: + case nir_op_fcos: + case nir_op_fsin: + return true; + default: + break; + } + + return false; +} + void ir2_nir_compile(struct ir2_context *ctx, bool binning) { @@ -1085,17 +1108,7 @@ ir2_nir_compile(struct ir2_context *ctx, bool binning) OPT_V(ctx->nir, nir_lower_bool_to_float); OPT_V(ctx->nir, nir_lower_to_source_mods, nir_lower_all_source_mods); - /* TODO: static bitset ? */ - BITSET_DECLARE(scalar_ops, nir_num_opcodes); - BITSET_ZERO(scalar_ops); - BITSET_SET(scalar_ops, nir_op_frsq); - BITSET_SET(scalar_ops, nir_op_frcp); - BITSET_SET(scalar_ops, nir_op_flog2); - BITSET_SET(scalar_ops, nir_op_fexp2); - BITSET_SET(scalar_ops, nir_op_fsqrt); - BITSET_SET(scalar_ops, nir_op_fcos); - BITSET_SET(scalar_ops, nir_op_fsin); - OPT_V(ctx->nir, nir_lower_alu_to_scalar, scalar_ops); + OPT_V(ctx->nir, nir_lower_alu_to_scalar, ir2_alu_to_scalar_filter_cb, NULL); OPT_V(ctx->nir, nir_lower_locals_to_regs); -- cgit v1.2.3