From nobody Sun Feb 8 21:49:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1769496002; cv=none; d=zohomail.com; s=zohoarc; b=eEPpbdRVH3Vs3/9XpoDCcoNISzQmr+lrb91hiSevKdBQvTqjPw8yb1o+hKqJ+Jj6A6VifDq1acCjUQXusoUS6HDFSh5wwzHf9RXRZHk3CKSTyTTS8N02Y1rwjnNQlLAhEbzKVp0Q3wJWDW7bap7yuOq4wZCTJcFPGR99HmtEF9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769496002; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FIZ+8DhFMV5di51oJwROCHq2vvo+jCjrZCBVlKzi/NE=; b=I7WuN6sE7dygGgqhJrNqr97hTSYb6c3HhMhEhBOOGpf+Od2UhBJGwXpYc+K+PBSZEWK/4tmDTyn2NXDX+aCmuoMBVXWs0f9iwbJ5t7HQF4AScMpATocpSGOsmhDSRZ+hRVvDTvN2ngmO8J9/sKVlNa6BVRVj60X/SQqMvESmxbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769496002464220.87183068483796; Mon, 26 Jan 2026 22:40:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkci7-0002sd-3G; Tue, 27 Jan 2026 01:38:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkci2-0002ra-IT for qemu-devel@nongnu.org; Tue, 27 Jan 2026 01:37:54 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vkci0-0006jb-51 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 01:37:53 -0500 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3530715386cso4617711a91.2 for ; Mon, 26 Jan 2026 22:37:51 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-353f5f96293sm1414175a91.0.2026.01.26.22.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 22:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1769495871; x=1770100671; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FIZ+8DhFMV5di51oJwROCHq2vvo+jCjrZCBVlKzi/NE=; b=DOR6fOZw4/ZfK/dQsNqyzDPZvqGziZemqGuxNC8vW2Wk46r2eXHRe6Pp+iMNs9TB5D DrSp6S40mG8r2WriNaCXGm4W0uWuzYXItbipM04W9lVU5AddEUvjxIn348Q+jPBOzfnh 0nbVLHPlVjsEJ0DTLcko1GO14a1QT10TA5Nx9SlVeEsKonejPC2/4pQo06pGMYPLhkJG 9+st1yZvz7vfqtJ2JoqO9SNnh5l0vssnn07tWsAuwqqkd6iF0z/Tir3MWv74cPXOWPcL MW3f6ucxxpcDbBafVoXhzrhub1c7iAEuBM+OkNVdBRyJz2ElL6hlJbHNF9SxHbudPGh8 7ihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769495871; x=1770100671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FIZ+8DhFMV5di51oJwROCHq2vvo+jCjrZCBVlKzi/NE=; b=j/lWY9QsZ22VvpRy/DvJr424cQ+lvSrVvTFXsObLZl8Pd9Xdg3xa3lfIl3i8wCzzX0 616nEmstISlKu4yFXI01FG67pOtoGOZ8BdnqPKsXwDpOLATySmISyaAJfTDZSRggWQcs XXc5c1OOWb8iHcdTOu6d4KskTbnIuuJWF24jvGM4/6z8K5tFw1lUhZUx4PyZGDqyzBM+ FGls6k7JoZmoImejfnbVd/I57rSRSu/QGhcBmZPFEZBuo+sJXxwKKcvLVb9cT84oUdxW io6ah1W3+pTcg03O7QX1bQhxZHwVE+oAmmVgNelDxSmLiiJmhFy8UUbRkDWdNZkV27gt yrhg== X-Gm-Message-State: AOJu0Ywx1jlJwV6PY+CS5vRVWiGwH0aWoVTj3iJy1uhllWNhRN7C2C00 M46a0rcIWqSWacZdmVZMubzy1ZGC6hl2huALU9Dc46jaiymNuwB/XRMsKLe3DRZoNHmpKqzc/oh HcnxP62AwO2K3YU8mRzueXXIBzSeFEn5R14DqWDh0zh8eR6xNnmYtLVU9dwPaySqXhmveiLYVIP Go83Ms9phkSkVETFsItPHmVvRPJipL8ZiG3p5xFT22+A== X-Gm-Gg: AZuq6aJWkTJ0E8YxZHZMSZcd4vcttg+0+M5gOv0Mv+iDK7Dip95RUx0trKwiWsWZkwp h0N/3xDMN3so1fCisccVF1fWGXeBfv/QaCV2vswvo2a+LbSAK0hhX1T8yRHOTDzxWax1GlzSKm4 2WAmKyB306g/XS41vQ/wuxpoZxh1hrMo9oK/9vlNaEf9uf8BjI1PJyBSyxDwlTSE/+jx3pU8LrL vuQEu2q5h86Kk+E0nP2DvG6TVVSrFXb95LUzB5PTvxDV0yn4APVh2gcsnBaaeb8wVUxOUHToFJe 51GmaroxxnxxAVvEqJHRU3C5G9t8CPNknKbyz4I0aETg811+pOhtupN+aYZMnXQGubXLT7cEXqa s8GvWERGZP0Ga6hGWaVkXoSch7O/QrmzG6lIYzYM3e/6M2RSf04xxq5jGtmtyQV9g5J85QoklHX qcdGVHYJ7b8K3dH/TqcgN01IqM9nyMvXGzPrjCsYkCu0ikFJs5r6iYtdN802nJoB64U/F8EXbAp Os7Nn17DdLr3fIobxIwNNcR0A== X-Received: by 2002:a17:90b:2541:b0:33b:8ac4:1ac4 with SMTP id 98e67ed59e1d1-353fed945bbmr916050a91.35.1769495870685; Mon, 26 Jan 2026 22:37:50 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Aurelien Jarno , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , richard.henderson@linaro.org, Max Chou , Alistair Francis Subject: [PATCH v2 08/17] target/riscv: rvv: Make vfncvtbf16.f.f.w support BF16 to OFP8 conversion for Zvfofp8min extension Date: Tue, 27 Jan 2026 14:37:14 +0800 Message-ID: <20260127063723.442734-9-max.chou@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260127063723.442734-1-max.chou@sifive.com> References: <20260127063723.442734-1-max.chou@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=max.chou@sifive.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sifive.com) X-ZM-MESSAGEID: 1769496003324158500 Content-Type: text/plain; charset="utf-8" According to the Zvfofp8min extension, the vfncvtbf16.f.f.w instruction supports BF16 to OFP8 conversion without satuation when SEW is 8. And the VTYPE.altfmt field is used to select the OFP8 format. * altfmt =3D 0: BF16 to OFP8.e4m3 * altfmt =3D 1: BF16 to OFP8.e5m2 Signed-off-by: Max Chou --- target/riscv/insn_trans/trans_rvbf16.c.inc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvbf16.c.inc b/target/riscv/insn= _trans/trans_rvbf16.c.inc index 9aafd4d2ef..16f4403909 100644 --- a/target/riscv/insn_trans/trans_rvbf16.c.inc +++ b/target/riscv/insn_trans/trans_rvbf16.c.inc @@ -67,11 +67,20 @@ static bool trans_fcvt_s_bf16(DisasContext *ctx, arg_fc= vt_s_bf16 *a) static bool trans_vfncvtbf16_f_f_w(DisasContext *ctx, arg_vfncvtbf16_f_f_w= *a) { REQUIRE_FPU; - REQUIRE_ZVFBFMIN(ctx); =20 - if (opfv_narrow_check(ctx, a) && (ctx->sew =3D=3D MO_16)) { + if (opfv_narrow_check(ctx, a) && + ((ctx->sew =3D=3D MO_16 && ctx->cfg_ptr->ext_zvfbfmin) || + (ctx->sew =3D=3D MO_8 && ctx->cfg_ptr->ext_zvfofp8min))) { + gen_helper_gvec_3_ptr *fn; uint32_t data =3D 0; =20 + if (ctx->sew =3D=3D MO_16) { + fn =3D gen_helper_vfncvtbf16_f_f_w; + } else { + fn =3D ctx->altfmt ? gen_helper_vfncvtbf16_f_f_w_ofp8e5m2 : + gen_helper_vfncvtbf16_f_f_w_ofp8e4m3; + } + gen_set_rm_chkfrm(ctx, RISCV_FRM_DYN); =20 data =3D FIELD_DP32(data, VDATA, VM, a->vm); @@ -81,8 +90,7 @@ static bool trans_vfncvtbf16_f_f_w(DisasContext *ctx, arg= _vfncvtbf16_f_f_w *a) tcg_gen_gvec_3_ptr(vreg_ofs(ctx, a->rd), vreg_ofs(ctx, 0), vreg_ofs(ctx, a->rs2), tcg_env, ctx->cfg_ptr->vlenb, - ctx->cfg_ptr->vlenb, data, - gen_helper_vfncvtbf16_f_f_w); + ctx->cfg_ptr->vlenb, data, fn); finalize_rvv_inst(ctx); return true; } --=20 2.52.0