Module: Mesa Branch: main Commit: 6b4ed663a845a7e4fda7c60d0979698cef6c2d11 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b4ed663a845a7e4fda7c60d0979698cef6c2d11
Author: Alyssa Rosenzweig <[email protected]> Date: Thu Nov 24 20:40:48 2022 -0500 agx: Implement 8-bit sign extensions Long term, I think having i2i16 and i2i32 available with 8-bit sources should make lowering the rest of 8-bit away a bit easier. Short term, this avoids special casing 8-bit in the VBO lowering code. Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19996> --- src/asahi/compiler/agx_compile.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index e4936804cf0..506a5604a08 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1015,18 +1015,26 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr) case nir_op_i2i32: { - if (s0.size != AGX_SIZE_16) - unreachable("todo: more conversions"); - - return agx_iadd_to(b, dst, s0, agx_zero(), 0); + if (src_sz == 8) { + /* Sign extend in software, NIR likes 8-bit conversions */ + agx_index ishl16 = agx_bfi(b, agx_zero(), s0, agx_immediate(8), 0); + return agx_asr_to(b, dst, ishl16, agx_immediate(8)); + } else { + assert(s0.size == AGX_SIZE_16 && "other conversions lowered"); + return agx_iadd_to(b, dst, s0, agx_zero(), 0); + } } case nir_op_i2i16: { - if (s0.size != AGX_SIZE_32) - unreachable("todo: more conversions"); - - return agx_iadd_to(b, dst, s0, agx_zero(), 0); + if (src_sz == 8) { + /* Sign extend in software, NIR likes 8-bit conversions */ + agx_index ishl16 = agx_bfi(b, agx_zero(), s0, agx_immediate(8), 0); + return agx_asr_to(b, dst, ishl16, agx_immediate(8)); + } else { + assert (s0.size == AGX_SIZE_32 && "other conversions lowered"); + return agx_iadd_to(b, dst, s0, agx_zero(), 0); + } } case nir_op_iadd_sat:
