From nobody Tue Jul 28 08:05:07 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=1777270305; cv=none; d=zohomail.com; s=zohoarc; b=gFBtY5MFVF2zTR/+tLlyvFVFh9M66B0YnzT1zo1LNk0i7gTES2Vufkyc3fZiNCx0924E+tPNP7i3ZeWC465fCdHva+7zLM66r6MqpFSl52WOaoFSY4j8SKO4INZQQ5H9uBqQxZrx4z+cUSj/DT+/2dG8oZyKqKF5aOKi3Q88JLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777270305; 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=zkL3jPcMswiVx/VRRzQf1eV73SetidZ9/3wOAro8ohA=; b=N+xI8w65UOMbdQ3Q7fpDXxIWnbqy2lWx1bBYJ8I+bZyJnU71UiEGD/g+R9iGA8gmYPb+CHtsmNgDKlO5aPbJ6ocNiB5hKCDLCAl4J0+NmrNrNYSJ60zTlrAu0QK8fn0xr+1bh7NZ7JctndBfA7hbcUrt4tjBhwQHQrRjasIWyOs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777270305292372.8817672680908; Sun, 26 Apr 2026 23:11:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHFAW-0005ti-8t; Mon, 27 Apr 2026 02:10:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHFAJ-0005UV-4s for qemu-devel@nongnu.org; Mon, 27 Apr 2026 02:09:55 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wHFAG-0000t0-RZ for qemu-devel@nongnu.org; Mon, 27 Apr 2026 02:09:54 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-35dac556bb2so5532001a91.1 for ; Sun, 26 Apr 2026 23:09:52 -0700 (PDT) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-361410bac6dsm30290710a91.14.2026.04.26.23.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 23:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1777270191; x=1777874991; 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=zkL3jPcMswiVx/VRRzQf1eV73SetidZ9/3wOAro8ohA=; b=NwztRuMvz7YSeu28w6Uf2lcPAo0mOyaCfgZ2B30PnVkE8AOlthLOB6BE0N3ZfIbG3X 8o4i+FcxYbp2akK37ueZIUDQN6xD4oE7tHwg48unsk0pzDYdbuItbGDUFDvBTdB30+2i ysnbncjyPsudy0/IPImkRgkZDMSC2UPIs75N8muyhUzt5y53NUm3Se5IEUUKPeeDaQ6X Lsxl/imBGvC3g76btIEzRMUMev2SQRvyuzPxDVEnMBuIyMLT2kOOXV1+HWZrNoBO+910 Ln21zm1LUv7bGKQSl1vkMIc3c8ToFABRWn1vCGs/18IHNqtWiA+jE1g2suIy2BI0JJbk V7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777270191; x=1777874991; 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=zkL3jPcMswiVx/VRRzQf1eV73SetidZ9/3wOAro8ohA=; b=GUt62L6XFjXlirRSPIgRMNXTHlDyFgQ+zRnpAz4emGz+0cw5c0qXRHE3obT9b5DAdl iyTnI8Q8LjRupvrGGgzIduiPa7ESEWxIYTWD+A1CqJCCOweKRcRcnvDvknpnAB4Ej3vW mjXieqIgJqiuCzgAKB5CivYW3EBPKq6eVtqyVext2ip8CljPZfAKFy2juFhiMjPip77e pOm2XqOFMFlqOwe48gLLcKakAFStrCAc2d39NdB5w6uPjEyf6p0OdJQQQczzl1oQ86x6 vgL8XXMsuAGwVP/8uB/ynvXvawREH7Nw8quUHW6jpg5WrrgrBo484Llr6Eo9DHmq1CaR WQzg== X-Gm-Message-State: AOJu0YwCW8DEJT9Oydo1mKkJEBZ8jQFt+2q5yBnn4pfBnqpSoOyHGJZT AhlbgDZcV1mpmsr6GurWQvjF3+gGr8uPAenCHrCwuzxEqx02Vhw1zPb9t3TT9CnCpb2E/bG+LFR xd4zDOGgNIAove9Hy19SFWzjQMiJFIFjkrW2neuWOHXD9hqakfy0ArUZns/9QmA5PSHqTRLTmZp 51/fmJ7X4dJ/ZotDiJJBM402Px2F3qtgyAPhFr6WA= X-Gm-Gg: AeBDiesj3GXqYjBZkR8DDDDILIS6x9TOs8zIftL69Mhy9WMQYGamda9zqYyQHjRY01z cYl/1B9EqSGb8Leze0iYVM17YdyiMTF3ZmDVEd3cjV2QJ8PBFzncd4LU18OJLnK9rHOeqj7DXyz 9O887Q0WFyNA8FY6F6gJiJLF0R8tq0IEyT9HygKf4E3LS47Qrl9aOsdNuTTi3AP+aGqqlRVi+Lq OQ6YK8chT0ZscS/vgK/wyxJeaQX7uq47o/6YFaVZSL+e3REW7iaug61zpg7Umn9BRhm0IopJcK7 IU0qX+VU6F0zSTR0ruhCDhCdsGvhiUyUO0175k3J8kctzeNIuYHzcjup7oyDhtUtA2S6NrU4Pkj sJt++X5l7iTIyye3IOviu9hdpJu5xacl69i/4/PhsptGSvHHTwAD+XyM3ah1bqIh+ZyQScEb9XI /SNjFpq/Sdj4/kyssazPVoEK1oMlvLRUiN6k2oqUuZEdWZHO2TXpDryc+NI1FStRRGXYRBYiYwh s94uanedSywnJOwEELgxtoTU6R9bFwjdaupLA== X-Received: by 2002:a17:90a:c10f:b0:35e:d012:5a39 with SMTP id 98e67ed59e1d1-361404650eemr40252315a91.14.1777270191320; Sun, 26 Apr 2026 23:09:51 -0700 (PDT) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Daniel Henrique Barboza , Weiwei Li , Liu Zhiwei , Chao Liu , Max Chou , Alistair Francis Subject: [PATCH v5 5/9] target/riscv: rvv: Make vfncvtbf16.f.f.w support BF16 to OFP8 conversion for Zvfofp8min extension Date: Mon, 27 Apr 2026 14:09:24 +0800 Message-ID: <20260427060928.2322570-6-max.chou@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427060928.2322570-1-max.chou@sifive.com> References: <20260427060928.2322570-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=max.chou@sifive.com; helo=mail-pj1-x102c.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: 1777270306120158500 Content-Type: text/plain; charset="utf-8" According to the Zvfofp8min extension, the vfncvtbf16.f.f.w instruction supports BF16 to OFP8 conversion without saturation 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 Reviewed-by: Chao Liu 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 86eb86f615..7e9b0a53a4 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