From be74b84e6f81c6a75e8488c0757ac7f911f4931d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 31 Dec 2020 22:14:42 -0500 Subject: [PATCH] pan/bi: Fill in some more conversions The trick is that downcasts are just swizzling out what you don't want, so things like U32_TO_F16 can be synthesized as V2U16_TO_V2F16 with src.h00 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index e12a8ab3cb0..30381a996b8 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -1798,16 +1798,20 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) break; case nir_op_f2u16: - if (src_sz == 32) - unreachable("should've been lowered"); - else + if (src_sz == 32) { + bi_mkvec_v2i16_to(b, dst, + bi_f32_to_u32(b, s0, BI_ROUND_RTZ), + bi_imm_u16(0)); + } else bi_v2f16_to_v2u16_to(b, dst, s0, BI_ROUND_RTZ); break; case nir_op_f2i16: - if (src_sz == 32) - unreachable("should've been lowered"); - else + if (src_sz == 32) { + bi_mkvec_v2i16_to(b, dst, + bi_f32_to_s32(b, s0, BI_ROUND_RTZ), + bi_imm_u16(0)); + } else bi_v2f16_to_v2s16_to(b, dst, s0, BI_ROUND_RTZ); break; @@ -1820,7 +1824,7 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) case nir_op_u2f16: if (src_sz == 32) - unreachable("should've been lowered"); + bi_v2u16_to_v2f16_to(b, dst, bi_half(s0, false), BI_ROUND_RTZ); else if (src_sz == 16) bi_v2u16_to_v2f16_to(b, dst, s0, BI_ROUND_RTZ); else if (src_sz == 8) @@ -1838,9 +1842,11 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) case nir_op_i2f16: if (src_sz == 32) - unreachable("should've been lowered"); - else + bi_v2s16_to_v2f16_to(b, dst, bi_half(s0, false), BI_ROUND_RTZ); + else if (src_sz == 16) bi_v2s16_to_v2f16_to(b, dst, s0, BI_ROUND_RTZ); + else if (src_sz == 8) + bi_v2s8_to_v2f16_to(b, dst, s0); break; case nir_op_i2f32: @@ -1864,14 +1870,13 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) bi_u8_to_u32_to(b, dst, s0); break; - /* todo optimize out downcasts */ case nir_op_i2i16: assert(src_sz == 8 || src_sz == 32); if (src_sz == 8) bi_v2s8_to_v2s16_to(b, dst, s0); else - bi_mkvec_v2i16_to(b, dst, bi_half(s0, false), bi_imm_u16(0)); + bi_mov_i32_to(b, dst, s0); break; case nir_op_u2u16: @@ -1880,7 +1885,7 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) if (src_sz == 8) bi_v2u8_to_v2u16_to(b, dst, s0); else - bi_mkvec_v2i16_to(b, dst, bi_half(s0, false), bi_imm_u16(0)); + bi_mov_i32_to(b, dst, s0); break; case nir_op_i2i8: