From patchwork Wed Jun 14 00:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 107637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp921232vqr; Tue, 13 Jun 2023 17:59:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cvJPMUr5hILcE1cwAZco1BEV/G8FvBAc0gcfD+DVkB4hGFc/zU+oEk5Aly9fF2UTZz2c+ X-Received: by 2002:a17:907:9611:b0:971:2eaf:556 with SMTP id gb17-20020a170907961100b009712eaf0556mr13924854ejc.18.1686704389331; Tue, 13 Jun 2023 17:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686704389; cv=none; d=google.com; s=arc-20160816; b=lv0tY3Yu6vQ4K+Jdwl6a0fGQwFsRTykM9kQnTR/BUNrkP+ReYq3hXLBtGo8Ih30GzL GqegGZrBinyBLy+hJXgQJ/SgGWiRdTkaPKbRohWzJ39QjwHMVWBCI5rgbQxR4xL/pCBA qbJ1WWsurO3scf+CHdXccOY/H+kqanWF2xgneuExTK3Nm/SaqpS3RHLBe6Bx29BRAH6W 5Vn9k4zZ993y3sqlc5Xy7GHkVAa3TlY+LWDeAThce5dVRvaMAwOttfxu6K01I4FWhT/8 Mx+/Ej654/rvTXYLfc3TJtn+wtKrdvCKOmkOvBUclX+uwEKX1h8zL4K0DiOE0LacMWU9 Ei8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5+ax2PeH7MhPXHmJg/A0WvfeuqPENK3bunRW/p7gPMY=; b=ECq7nIGRWxSUfVoPqfZbqiOhIqDVrN9Y42S9wN5t788tnDL+d+FlClbTORO1rPfq12 CkTEV7GPtNPafi9iU/78wOV+Cf1eR5HqHa+30djS46WbCaaYMTA7cTo9yuLu0q25wYdu GMvN+DaN0bvPubUkNN/sFYqRIlbafUzTlVorW520CE568Sv3e0J3nRWscQczhqLs+Syj WRS7m90HcL1yoiOkHDoTr2Qa90SnW0TVVkp7nUQrCrjXT18hZRHXPWfb5hswVHKuW8yt My2dLlzvFsE/djTZUBMjjWkftMboxX+51ooU0VuobotvvZYrDGEyNctHD+uTywLy6+g7 yy2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DsD6aJdc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l14-20020a170906414e00b0094effaaa050si7136947ejk.50.2023.06.13.17.59.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 17:59:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DsD6aJdc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02E533858404 for ; Wed, 14 Jun 2023 00:59:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02E533858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686704388; bh=5+ax2PeH7MhPXHmJg/A0WvfeuqPENK3bunRW/p7gPMY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=DsD6aJdcMlYi8qx8LbIQ3OnGHB96qGQW05t6IAXZtfojH2gbQdHl2RcKs8XQg5wOF tVAIfMScB+d6HnpPcFkEiKzh2TtmrjP+hgBpg3VGY/uRwmIPxGFu7HUX0WMkCfXsmT DDqA/dycwBuBOLMea0GL1BXMSkW/30yGuSA66dIw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 154703858D38 for ; Wed, 14 Jun 2023 00:59:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 154703858D38 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="360968225" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="360968225" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 17:59:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="715003601" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="715003601" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga007.fm.intel.com with ESMTP; 13 Jun 2023 17:59:00 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id EBC7B100514A; Wed, 14 Jun 2023 08:58:59 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, rdapp.gcc@gmail.com, jeffreyalaw@gmail.com, pan2.li@intel.com, yanzhang.wang@intel.com, kito.cheng@gmail.com Subject: [PATCH v1] RISC-V: Bugfix for vec_init repeating auto vectorization in RV32 Date: Wed, 14 Jun 2023 08:58:59 +0800 Message-Id: <20230614005859.960040-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768637741862842239?= X-GMAIL-MSGID: =?utf-8?q?1768637741862842239?= From: Pan Li This patch would like to fix one bug exported by RV32 test case multiple_rgroup_run-2.c. The mask should be restricted by elen in vector, and the condition between the vmv.s.x and the vmv.v.x should take inner_bits_size rather than constants. Passed both the rv32 and rv64 riscv/rvv tests. Signed-off-by: Pan Li gcc/ChangeLog: * config/riscv/riscv-v.cc (rvv_builder::get_merge_scalar_mask): Take elen instead of scalar BITS_PER_WORD. (expand_vector_init_merge_repeating_sequence): Use inner_bits_size instead of scaler BITS_PER_WORD. Signed-off-by: Pan Li --- gcc/config/riscv/riscv-v.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index fb970344521..9270e258ca3 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -399,10 +399,11 @@ rvv_builder::get_merge_scalar_mask (unsigned int index_in_pattern) const { unsigned HOST_WIDE_INT mask = 0; unsigned HOST_WIDE_INT base_mask = (1ULL << index_in_pattern); + unsigned int elen = TARGET_VECTOR_ELEN_64 ? 64 : 32; - gcc_assert (BITS_PER_WORD % npatterns () == 0); + gcc_assert (elen % npatterns () == 0); - int limit = BITS_PER_WORD / npatterns (); + int limit = elen / npatterns (); for (int i = 0; i < limit; i++) mask |= base_mask << (i * npatterns ()); @@ -1923,7 +1924,7 @@ expand_vector_init_merge_repeating_sequence (rtx target, rtx mask = gen_reg_rtx (mask_mode); rtx dup = gen_reg_rtx (dup_mode); - if (full_nelts <= BITS_PER_WORD) /* vmv.s.x. */ + if (full_nelts <= builder.inner_bits_size ()) /* vmv.s.x. */ { rtx ops[] = {dup, gen_scalar_move_mask (dup_mask_mode), RVV_VUNDEF (dup_mode), merge_mask}; @@ -1933,7 +1934,8 @@ expand_vector_init_merge_repeating_sequence (rtx target, else /* vmv.v.x. */ { rtx ops[] = {dup, force_reg (GET_MODE_INNER (dup_mode), merge_mask)}; - rtx vl = gen_int_mode (CEIL (full_nelts, BITS_PER_WORD), Pmode); + rtx vl = gen_int_mode (CEIL (full_nelts, builder.inner_bits_size ()), + Pmode); emit_nonvlmax_integer_move_insn (code_for_pred_broadcast (dup_mode), ops, vl); }