From 8eefb2765ab2253fe99ddf3ae32a2a901046d8d1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 5 Apr 2020 19:22:01 -0400 Subject: [PATCH] pan/bi: Match CSEL argument order with hw It turns out ports need to be in order of the arguments of an instruction (port 3, that is), which breaks on instructions whose IR argument order is different from the packed order, like csel. So fix that. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 8 ++++---- src/panfrost/bifrost/bifrost_compile.c | 16 +++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 8c91c0436d2..ea68aa41b37 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -691,10 +691,10 @@ bi_pack_fma_csel(bi_instruction *ins, struct bi_registers *regs) unsigned size = nir_alu_type_get_type_size(ins->dest_type); - unsigned cmp_0 = (flip ? 3 : 0); - unsigned cmp_1 = (flip ? 0 : 3); - unsigned res_0 = (invert ? 2 : 1); - unsigned res_1 = (invert ? 1 : 2); + unsigned cmp_0 = (flip ? 1 : 0); + unsigned cmp_1 = (flip ? 0 : 1); + unsigned res_0 = (invert ? 3 : 2); + unsigned res_1 = (invert ? 2 : 3); struct bifrost_csel4 pack = { .src0 = bi_get_src(ins, regs, cmp_0, true), diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 0eced9713da..869e353624e 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -520,7 +520,7 @@ bi_fuse_csel_cond(bi_instruction *csel, nir_alu_src cond, /* We found one, let's fuse it in */ csel->csel_cond = bcond; bi_copy_src(csel, alu, 0, 0, constants_left, constant_shift); - bi_copy_src(csel, alu, 1, 3, constants_left, constant_shift); + bi_copy_src(csel, alu, 1, 1, constants_left, constant_shift); } static void @@ -571,8 +571,14 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) unsigned num_inputs = nir_op_infos[instr->op].num_inputs; assert(num_inputs <= ARRAY_SIZE(alu.src)); - for (unsigned i = 0; i < num_inputs; ++i) - bi_copy_src(&alu, instr, i, i, &constants_left, &constant_shift); + for (unsigned i = 0; i < num_inputs; ++i) { + unsigned f = 0; + + if (i && alu.type == BI_CSEL) + f++; + + bi_copy_src(&alu, instr, i, i + f, &constants_left, &constant_shift); + } /* Op-specific fixup */ switch (instr->op) { @@ -642,8 +648,8 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) if (alu.type == BI_CSEL) { /* Default to csel3 */ alu.csel_cond = BI_COND_NE; - alu.src[3] = BIR_INDEX_ZERO; - alu.src_types[3] = alu.src_types[0]; + alu.src[1] = BIR_INDEX_ZERO; + alu.src_types[1] = alu.src_types[0]; bi_fuse_csel_cond(&alu, instr->src[0], &constants_left, &constant_shift); -- 2.30.2