From nobody Sun May 11 01:48:10 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail  header.i=@wdc.com;
	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=fail(p=none dis=none)  header.from=wdc.com
ARC-Seal: i=1; a=rsa-sha256; t=1620730535; cv=none;
	d=zohomail.com; s=zohoarc;
	b=HBc+TegtiogAT3wmEgQRReGSTcQXfkEPshQXgSurOe1OGZ4klhoHSo6tew4whZBEG67Dqm07aFDoAWg4DBlQ1Iqeh434JRpTwIjlGYkOTPJ9DuGI2yfG7pWavyY8Px6QdiSmF4Giik2WLCyRNg54/s/CRZQWf0pxCgAey0v9oNE=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1620730535;
 h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To;
	bh=w7W01WPquuQ6NqRcsmADBLVWP/nbEqECish+hcCTgjQ=;
	b=Q5w2gRcuyzGnGUycPTuYWHeHKSGHjovkTd3XqaP2pRIBVib7JEACugObWDptXlNfk38/7U3+jCbwsBrr/FLu+JzWqXM2apWDmozj7lEuSYu4g1xhukVdXTtzKgyO1XLm8D227Grog3tcVdMqiKf7r9IPo4iRlS9v2nrkxNkdguc=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=fail  header.i=@wdc.com;
	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=fail header.from=<alistair.francis@wdc.com> (p=none dis=none)
 header.from=<alistair.francis@wdc.com>
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1620730535078304.23292082539933;
 Tue, 11 May 2021 03:55:35 -0700 (PDT)
Received: from localhost ([::1]:39454 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1lgQ33-0005vX-V6
	for importer@patchew.org; Tue, 11 May 2021 06:55:34 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38326)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1)
 (envelope-from <prvs=7584e029c=alistair.francis@wdc.com>)
 id 1lgPWr-00028a-Jg
 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:18 -0400
Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1)
 (envelope-from <prvs=7584e029c=alistair.francis@wdc.com>)
 id 1lgPWn-0006TG-S1
 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:17 -0400
Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com)
 ([199.255.45.14])
 by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:34 +0800
Received: from uls-op-cesaip01.wdc.com ([10.248.3.36])
 by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 11 May 2021 03:01:34 -0700
Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48])
 by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:33 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
 d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com;
 t=1620728532; x=1652264532;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=HRFnRKpT6eIKGkJmmSWcNkwah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MugPgvs9x3AE6jzzd1Yq
IronPort-SDR: 
 KSrScgw1pJ94opK/R7DkGNihmFrBDAWgt7Pjl9faDJ6neChGlVXT7aVbUXfoBR5Cu77FAreiEh
 zT95h3L/tIEZYtquN8R/ZHw+48DQQMrUBmKxCp52XxyzxV/vVH4YZGAt16+35Q70pqdAHYpoI3
 zQNxRhy170EaKGEY9mmbMN6LsPymdzzuKTVVPZK4KZoyOJSoAaosTvMfsspFx9dpy2dDOnT2YQ
 4G78PHSayYlKzwnShgl+ZgcoeQZIe1TEKmR1shkisKCOcQC0KtRCaMLycArDodfu3ddfi73HzW
 k20=
WDCIronportException: Internal
From: Alistair Francis <alistair.francis@wdc.com>
To: peter.maydell@linaro.org
Subject: [PULL v3 28/42] target/riscv: fix vrgather macro index variable type
 bug
Date: Tue, 11 May 2021 20:19:37 +1000
Message-Id: <20210511101951.165287-29-alistair.francis@wdc.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com>
References: <20210511101951.165287-1-alistair.francis@wdc.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=216.71.153.144;
 envelope-from=prvs=7584e029c=alistair.francis@wdc.com;
 helo=esa5.hgst.iphmx.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: Frank Chang <frank.chang@sifive.com>, alistair23@gmail.com,
 Alistair Francis <alistair.francis@wdc.com>,
 Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
Content-Type: text/plain; charset="utf-8"

From: Frank Chang <frank.chang@sifive.com>

ETYPE may be type of uint64_t, thus index variable has to be declared as
type of uint64_t, too. Otherwise the value read from vs1 register may be
truncated to type of uint32_t.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210419060302.14075-1-frank.chang@sifive.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/vector_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 356cef8a09..4651a1e224 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -4796,7 +4796,8 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void=
 *vs2,               \
     uint32_t vlmax =3D env_archcpu(env)->cfg.vlen / mlen;                 =
  \
     uint32_t vm =3D vext_vm(desc);                                        =
  \
     uint32_t vl =3D env->vl;                                              =
  \
-    uint32_t index, i;                                                    \
+    uint64_t index;                                                       \
+    uint32_t i;                                                           \
                                                                           \
     for (i =3D 0; i < vl; i++) {                                          =
  \
         if (!vm && !vext_elem_mask(v0, mlen, i)) {                        \
@@ -4826,7 +4827,8 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1=
, void *vs2,         \
     uint32_t vlmax =3D env_archcpu(env)->cfg.vlen / mlen;                 =
  \
     uint32_t vm =3D vext_vm(desc);                                        =
  \
     uint32_t vl =3D env->vl;                                              =
  \
-    uint32_t index =3D s1, i;                                             =
  \
+    uint64_t index =3D s1;                                                =
  \
+    uint32_t i;                                                           \
                                                                           \
     for (i =3D 0; i < vl; i++) {                                          =
  \
         if (!vm && !vext_elem_mask(v0, mlen, i)) {                        \
--=20
2.31.1