From d43c0f35ff1ec0fe05531233afdeabd3281c4140 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 31 Dec 2020 16:03:38 -0500 Subject: [PATCH] pan/bi: Implement vectorized f32_to_f16 f2f16 needs special treatment since it can access multiple 32-bit words. Corresponds to the two-op instruction V2F32_TO_V2F16. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 0b7bae63c9e..5c49cb5d521 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -1522,9 +1522,9 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) { bi_index dst = bi_dest_index(&instr->dest.dest); unsigned sz = nir_dest_bit_size(instr->dest.dest); - unsigned srcs = nir_op_infos[instr->op].num_inputs; unsigned comps = nir_dest_num_components(instr->dest.dest); + unsigned src_sz = srcs > 0 ? nir_src_bit_size(instr->src[0].src) : 0; if (!instr->dest.dest.is_ssa) { for (unsigned i = 0; i < comps; ++i) @@ -1598,6 +1598,16 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) return; } + case nir_op_f2f16: + assert(src_sz == 32); + bi_index idx = bi_src_index(&instr->src[0].src); + bi_index s0 = bi_word(idx, instr->src[0].swizzle[0]); + bi_index s1 = comps > 1 ? + bi_word(idx, instr->src[0].swizzle[1]) : s0; + + bi_v2f32_to_v2f16_to(b, dst, s0, s1, BI_ROUND_NONE); + return; + default: break; } @@ -1606,8 +1616,6 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) bi_index s1 = srcs > 1 ? bi_alu_src_index(instr->src[1], comps) : bi_null(); bi_index s2 = srcs > 2 ? bi_alu_src_index(instr->src[2], comps) : bi_null(); - unsigned src_sz = srcs > 0 ? nir_src_bit_size(instr->src[0].src) : 0; - switch (instr->op) { case nir_op_ffma: bi_fma_to(b, sz, dst, s0, s1, s2, BI_ROUND_NONE); @@ -1783,10 +1791,6 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) break; } - case nir_op_f2f16: - bi_v2f32_to_v2f16_to(b, dst, s0, s0, BI_ROUND_NONE); - break; - case nir_op_f2f32: bi_f16_to_f32_to(b, dst, s0); break;