From ed2351e4f06d6953f8f6593c9e66c76b3a9148c4 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Wed, 25 Nov 2026 09:42:45 +0100 Subject: [PATCH] asahi: route G18G rounding ops through shared AGX3c unary encoder for FP16 support In agx3_emit_funop() (agx3_pack_binary.c), AGX3_FUNOP_RINT on G18G already fell through to agx3_alu_unary_m5(), which emits the same AGX3_MN_f32rint fields while supporting 16-bit half operands and high registers (0..255). FLOOR, CEIL, and TRUNC on G18G were still routed to agx3_funop_encode_g17g(), which refuses 16-bit rounding operands. Route all four rounding operations (FLOOR, CEIL, TRUNC, RINT) on G18G through agx3_alu_unary_m5() so FP16 ceil/floor/trunc/roundEven encode cleanly and transcode to AGX3D. Signed-off-by: Thomas Glanzmann --- src/asahi/compiler/agx3_pack_binary.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/asahi/compiler/agx3_pack_binary.c b/src/asahi/compiler/agx3_pack_binary.c index 452feccdb222..294ff84f79cd 100644 --- a/src/asahi/compiler/agx3_pack_binary.c +++ b/src/asahi/compiler/agx3_pack_binary.c @@ -955,11 +955,12 @@ agx3_emit_funop(struct util_dynarray *emission, enum agx_isa_encoding enc, const agx_instr *I, enum agx3_funop op, uint16_t wait_mask, bool g18g) { - /* G18G (agx3d) keeps j873's G17G-family unary encoder for its rounding, - * log/exp, rsqrt and sqrt-step forms. */ - if (g18g && enc == AGX_ISA_ENCODING_AGX3C && op != AGX3_FUNOP_RINT && - (op <= AGX3_FUNOP_EXP2 || op == AGX3_FUNOP_RSQRT || - op == AGX3_FUNOP_SQRT_STEP)) { + /* G18G (agx3d) keeps j873's G17G-family unary encoder for log/exp, rsqrt + * and sqrt-step; rounding ops (floor/ceil/trunc/rint) use the shared + * AGX3c unary encoder below so 16-bit and high-register forms encode too. */ + if (g18g && enc == AGX_ISA_ENCODING_AGX3C && + ((op > AGX3_FUNOP_RINT && op <= AGX3_FUNOP_EXP2) || + op == AGX3_FUNOP_RSQRT || op == AGX3_FUNOP_SQRT_STEP)) { if (I->nr_dests != 1 || I->nr_srcs != 1 || I->dest[0].type == AGX_INDEX_NULL || !agx3_src_is_register(I->dest[0]) || I->dest[0].memory ||