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: