Module: Mesa
Branch: master
Commit: be74b84e6f81c6a75e8488c0757ac7f911f4931d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be74b84e6f81c6a75e8488c0757ac7f911f4931d

Author: Alyssa Rosenzweig <[email protected]>
Date:   Thu Dec 31 22:14:42 2020 -0500

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10065>

---

 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:

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to